Copied to clipboard

Flag this post as spam?

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


  • Kevin Walker 66 posts 87 karma points
    Feb 18, 2011 @ 13:14
    Kevin Walker
    0

    Friendly URLs when inserting a pagefield into a Template

    Hi Guys

    When I insert an umbraco page field (of type Content Picker) directly into a template in order to link to another page within my website, the URL returned front side is /235 which is the ID of the node I wish to link to. What is the best way to return the friendly URL in this instance where we are not dealing with XSLT nor User Control and simply want the friendly URL to be in the template when published?

    Many thanks in advance.

    Kevin

  • elspiko 133 posts 302 karma points
    Feb 18, 2011 @ 13:24
    elspiko
    0

    Hi Kevin,

    Forgive me, but if you're pulling the link into the front end, why not use the NiceUrl library method to generate the correct url?

    Cheers

    Richard

  • Kevin Walker 66 posts 87 karma points
    Feb 18, 2011 @ 13:27
    Kevin Walker
    0

    Thanks for the reply, do you have an example of using this library method in conjuction with the page field in a template. At the moment the page fields looks as follows in the template:

    <div id="virtualtourlink"><a href="<umbraco:Item field="featureLink1Link" runat="server"></umbraco:Item>" title="Take a Virtual Tour">Click here to view our Virtual Tour</a></div>

  • elspiko 133 posts 302 karma points
    Feb 18, 2011 @ 15:13
    elspiko
    1

    If featureLink1Link is only the node id, you could replace the current umbraco:Item control with:

    <umbraco:Item field="featureLink1Link" xslt="umbraco.library:NiceUrl({0})" runat="server"></umbraco:Item>
  • Kevin Walker 66 posts 87 karma points
    Feb 18, 2011 @ 15:26
    Kevin Walker
    0

    Brilliant, thanks elspiko, that works perfectly and is exactly what I needed. 

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft