<p>If you change the entry type then you're going to lose content for sure.</p>

<p>If changing that field type to an entry is really what you want, great. You could do something like</p>

<pre><code>{# grab the first entry that we've selected #}
{% set learnMoreLink = box.learnMoreLink.first() %}
{# spit out the url for the first entry #}
&lt;a href="{{ learnMoreLink.url }}"&gt;{{ box.learnMoreText }}&lt;/a&gt;
</code></pre>

CC BY-SA 3.0
2017-07-17T17:55:55.880Z
Hey, thanks for replying.

I replaced "<a href="{{box.learnMoreLink}}"> {{ box.learnMoreText }} </a>" with your code snippet and it didn't work. The content is still getting lost.
user6999
CC BY-SA 3.0
2017-07-17T20:39:43.850Z
Have you actually defined the relationship after changing the field type?
Steven Grant
CC BY-SA 3.0
2017-07-17T21:27:31.647Z
I am not totally sure what you mean by 'defining the relationship'. Could you please elaborate? Sorry, I am new to craft.

All I did was change the field type from 'plain text' to 'entry' in the CMS and then replaced my <a> tag code with your snippet.
user6999
CC BY-SA 3.0
2017-07-17T21:47:21.253Z
So if you've only changed it from plain text to entry, you're only part way there, next you'll need to edit the entry and then select the entry that you want the button to link to, save that entry and then the code above should work. Plain text and entry store entirely different things in the database. It won't auto transform.
Steven Grant
CC BY-SA 3.0
2017-07-14T06:54:27.313Z
2017-07-14T06:54:27.313Z
Steven Grant
<pre><code>&lt;a href="{{box.learnMoreLink}}"&gt; {{ box.learnMoreText }} &lt;/a&gt; 
</code></pre>

<p>Currently I have a Matrix field that has two plain-text fields. I want to change the href (<code>{{box.learnMoreLink}}</code>) from plain-text to an entry. I am trying to figure out how to render the entry field. Just changing the field type in the CMS is resulting in content loss. Anyone know the best way to go about this?</p>

CC BY-SA 3.0
2017-07-13T22:53:36.820Z
Can you explain why you want to change to an entry field? Is there a link field on the entry field you want to use instead?
Brad Bell
CC BY-SA 3.0
2017-07-17T21:33:44.227Z
I want to change it to an entry field to make the url dynamic. I tried setting up {{siteUrl}} but that didn't work.
user6999
<templating><matrix><entry><entry-type><entries-field>
How to render an entry type of a Matrix in HTML?
# How to render an entry type of a Matrix in HTML?

(Asked by: username_0 on 2017-07-13)

{{ box.learnMoreText }}  

Currently I have a Matrix field that has two plain-text fields. I want to change the href ({{box.learnMoreLink}}) from plain-text to an entry. I am trying to figure out how to render the entry field. Just changing the field type in the CMS is resulting in content loss. Anyone know the best way to go about this?

**Tags:** templating, matrix, entry, entry-type, entries-field
> **Comments:**
> **username_1**: Can you explain why you want to change to an entry field? Is there a link field on the entry field you want to use instead?  
> **username_0**: I want to change it to an entry field to make the url dynamic. I tried setting up {{siteUrl}} but that didn't work.  

---

## 1 answers

### Answer by username_2 on 2017-07-14. Score: 1 | Accepted answer

If you change the entry type then you're going to lose content for sure.
If changing that field type to an entry is really what you want, great. You could do something like
{# grab the first entry that we've selected #}
{% set learnMoreLink = box.learnMoreLink.first() %}
{# spit out the url for the first entry #}
{{ box.learnMoreText }}

> **Comments:**
> **username_0**: Hey, thanks for replying.  I replaced "<a href="{{box.learnMoreLink}}"> {{ box.learnMoreText }} </a>" with your code snippet and it didn't work. The content is still getting lost.  
> **username_2**: Have you actually defined the relationship after changing the field type?  
> **username_0**: I am not totally sure what you mean by 'defining the relationship'. Could you please elaborate? Sorry, I am new to craft.  All I did was change the field type from 'plain text' to 'entry' in the CMS and then replaced my <a> tag code with your snippet.  
> **username_2**: So if you've only changed it from plain text to entry, you're only part way there, next you'll need to edit the entry and then select the entry that you want the button to link to, save that entry and then the code above should work. Plain text and entry store entirely different things in the database. It won't auto transform.  

---

