Using NiceUrl inside a template together with a page field?
Hi.
I have a page where the layout is extremely restricted for the user. However, the content isn't. So, they therefor need to input the title, text and then pick the page which the element should link to. All the markup is thus in the background. The link is picked using a regular Content Picker.
The page they pick (box1Link in this case), I grab into the template like so:
However, the link then doesn't become /consulting-services/ like it should, but rather /1288/. Not great. So I was thinking that I could use NiceUrl? But I don't know how to do that outside of XSLT. Is it possible? I feel that using an external external XSLT file is rather excessive in this scenario.
Using NiceUrl inside a template together with a page field?
Hi.
I have a page where the layout is extremely restricted for the user. However, the content isn't. So, they therefor need to input the title, text and then pick the page which the element should link to. All the markup is thus in the background. The link is picked using a regular Content Picker.
The page they pick (box1Link in this case), I grab into the template like so:
<umbraco:Item field="box1Link" insertTextBefore="<a class="item item1" href="" insertTextAfter="">" runat="server" />
However, the link then doesn't become /consulting-services/ like it should, but rather /1288/. Not great. So I was thinking that I could use NiceUrl? But I don't know how to do that outside of XSLT. Is it possible? I feel that using an external external XSLT file is rather excessive in this scenario.
Thankful for help on this.
Hey Patrik,
You an either use
Or
<a href='<umbraco:Item runat="server" field="box1Link" xslt="umbraco.library:NiceUrl({0})" />' >More info</a>
However if the link is not mandatory I would use a separate XSLT macro, you can re-use it for every link, just pass it the ID via a parameter.
Rich
@Rich Green
Thanks, that worked perfectly! I chose the second suggestion as it seemed an awful lot more readable :)
is working on a reply...