Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Patrik 10 posts 30 karma points
    Nov 25, 2011 @ 08:34
    Patrik
    0

    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="&lt;a class=&quot;item item1&quot; href=&quot;" insertTextAfter="&quot;&gt;" 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.

  • Rich Green 2246 posts 4008 karma points
    Nov 25, 2011 @ 09:29
    Rich Green
    1

    Hey Patrik,

    You an either use

    <a href="{localLink:<umbraco:Itemfield='box1Link'runat='server'></umbraco:Item>}">More Info</a>

    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

  • Patrik 10 posts 30 karma points
    Nov 25, 2011 @ 13:40
    Patrik
    0

    @Rich Green

    Thanks, that worked perfectly! I chose the second suggestion as it seemed an awful lot more readable :)

Please Sign in or register to post replies

Write your reply to:

Draft