Copied to clipboard

Flag this post as spam?

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


  • Deepali Bhola 23 posts 43 karma points
    Aug 08, 2012 @ 17:57
    Deepali Bhola
    0

    internal page linking with anchor tag

    Well, It’s seems stupid question but I can't figure out how to do this,

    like if somewhere in my html I want to redirect to another umbraco page how do i do this.

    <a href="somepage.aspx">somepage</a> ?

    if yes then what about nested sub page?

    i want to know the best practice to do this.

    Thanks

     

  • Dan 1285 posts 3917 karma points c-trib
    Aug 08, 2012 @ 18:13
    Dan
    0

    Hi Deepali,

    You can just use normal page URLs like your example above, but best to put a slash at the start so the path is always relative to your document root.  Note, the drawback with this method is is that if the page name changes your link will break.  So to tackle this you could use the following syntax:

    <a href="/{localLink:1610}" title="Some page">Some page</a>

    Where the number is the id of the page node (which you can find in the properties tab of the page in the content section).  Umbraco will swap this out before rendering and will output a standard relative link. This way, even if the page name changes the link will be maintained.

  • Deepali Bhola 23 posts 43 karma points
    Aug 09, 2012 @ 09:24
    Deepali Bhola
    0

    Thanks alot Dan,

    It works like Charm!!

    : )

  • bob singh 47 posts 126 karma points
    Apr 23, 2013 @ 18:26
    bob singh
    0

    Hi Dan,

    This does not work for me as all I am getting is the node id instead of the web page name.

    Bob

  • Dan 1285 posts 3917 karma points c-trib
    Apr 23, 2013 @ 18:30
    Dan
    0

    Hi Bob,

    I think the formatting on the forum might screw this up, as I think it has done above, but inside the href attribute, try putting {localLink:1099} including the curly braces, where the number is the id of the node you want to link to.

  • bob singh 47 posts 126 karma points
    Apr 23, 2013 @ 19:02
    bob singh
    0

    Hi Dan,

    Say for example I have a related links object called abc, when i call this object in the xslt    

    <a href="{abc)}">

                      <img src="{umbracoFile}" width="500" height="320" />
                        </a>

    it should output the page i.e mysite.com/news.aspx and not mysite.com/1234?

    This is a basic function as there are loads of images all over the website that require linking to internal webpages.

  • bob singh 47 posts 126 karma points
    Apr 24, 2013 @ 10:01
    bob singh
    0

    Hi guys,

    Im just going to hardcode the links thanks for your help

    Bob

  • Dan 1285 posts 3917 karma points c-trib
    Apr 24, 2013 @ 10:08
    Dan
    0

    Ah, you're doing this in XLST?  The above is for directly in templates.  In XSLT to render a URL from a node id you'll need to do something like this:

    <a href="{umbraco.library:NiceUrl($abc)}"><img src="somthing.jpg" /></a>

    Where $abc is the node id variable.

Please Sign in or register to post replies

Write your reply to:

Draft