Copied to clipboard

Flag this post as spam?

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

  • Luke Johnson 61 posts 80 karma points
    Jun 27, 2011 @ 22:26
    Luke Johnson

    Display current page URL

    How do I go about accessing the current page's URL?

    I am trying to dynamically generate Facebook Comments widgets on news and announcement pages. I would like these widgets to be page-specific so that the same comments don't appear on every single story or page.

    So far I've been playing with this code:

      <fb:comments href='<umbraco:Item field="pageID" runat="server"/>' num_posts="16" width="680"></fb:comments>

    This returns the appropriate page ID, but this doesn't link properly with Facebook. I need the actual page URL ( to be inserted into the link.

    Should I be attempting this in XSLT instead?

  • skiltz 501 posts 701 karma points
    Jun 27, 2011 @ 22:43


    <umbraco:Item field='pageID' xslt="umbraco.library:NiceUrl({0})" runat='server' />

  • Tom Fulton 2030 posts 4989 karma points c-trib
    Jun 27, 2011 @ 22:44
    Tom Fulton


    You need to call the umbraco.library:NiceUrl function to convert the page ID to a URL.  I think you could achieve this using the umbraco:Item tag with inline XSLT:

    <umbraco:Item field="pageID" runat="server" Xslt="umbraco.library:NiceUrl({0})" />

    If not, it's easy to do from XSLT:

    <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/>

    Note, you might need to add the domain name before the Item tag, as NiceUrl won't return it unless you have some options set.


  • Luke Johnson 61 posts 80 karma points
    Jun 27, 2011 @ 22:48
    Luke Johnson

    Inline XSLT - nice! That worked perfectly! Thank-you.

Please Sign in or register to post replies

Write your reply to: