Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey Guys,
This is probably a stupid question, but i cant seem to find an appropriate answer.
What i need to do is use an Umbraco.Field in a href in a template, just like this piece of code:
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <a href="@Umbraco.Field("boks2Link")" target="_blank" class="hover-effect"> <img class="img-responsive margin-top Info-Aside-Shadow" src="@Umbraco.Media(CurrentPage.gaaTilBoks2Billede).Url" alt="Se programmer"> <div class="HeadLineTilbud"> <h2>@Umbraco.Field("gaaTilBoks2")</h2> </div> </a> </div>
However, i can't use @Umbraco.Field("boks2Link") in href.
What should i do to make this work?
Thank you very much in advance!
Kind regards, Magnus
It depends what bok2Link is, but I'm going to use it is a content picker for this answer in which case this should work:
@{ var boks2LinkItem = Umbraco.TypedContent(Umbraco.Field("boks2Link")); } <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <a href="@boks2LinkItem.Url" target="_blank" class="hover-effect"> <img class="img-responsive margin-top Info-Aside-Shadow" src="@Umbraco.Media(CurrentPage.gaaTilBoks2Billede).Url" alt="Se programmer"> <div class="HeadLineTilbud"> <h2>@Umbraco.Field("gaaTilBoks2")</h2> </div> </a> </div>
Hey David,
Thank you for your answer!
Your solution doesn't seem to work as boks2Link is an external URL in a "Text Box" field. However i changed the code slightly which made it work.
@{ var boks2LinkItem = Umbraco.Field("boks2Link"); } <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <a href="@boks2LinkItem" target="_blank" class="hover-effect"> <img class="img-responsive margin-top Info-Aside-Shadow" src="@Umbraco.Media(CurrentPage.gaaTilBoks2Billede).Url" alt="Se programmer"> <div class="HeadLineTilbud"> <h2>@Umbraco.Field("gaaTilBoks2")</h2> </div> </a> </div>
I thought i had tried this already, but now it works!
Thanks a lot!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to use umbraco.field in href
Hey Guys,
This is probably a stupid question, but i cant seem to find an appropriate answer.
What i need to do is use an Umbraco.Field in a href in a template, just like this piece of code:
However, i can't use @Umbraco.Field("boks2Link") in href.
What should i do to make this work?
Thank you very much in advance!
Kind regards, Magnus
It depends what bok2Link is, but I'm going to use it is a content picker for this answer in which case this should work:
Hey David,
Thank you for your answer!
Your solution doesn't seem to work as boks2Link is an external URL in a "Text Box" field. However i changed the code slightly which made it work.
I thought i had tried this already, but now it works!
Thanks a lot!
is working on a reply...