Copied to clipboard

Flag this post as spam?

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


  • Pete 213 posts 285 karma points
    Jul 29, 2011 @ 16:42
    Pete
    0

    Can't get value of umbracoUrlAlias property

    I'm trying to return the umbracoUrlAlias property but struggling, I must be missing something.

    I have in a document type a generic property called "Related Url", and it's alias is umbracoUrlAlias, it is a textstring.

    On the page's content I have set the "Related Url" set to /index.aspx.

    In the navigation xlst <a href="{umbraco.library:NiceUrl(@id)}"> returns the path no problem but

    <a href="{data[@alias='umbracoUrlAlias']}"> returns nothing.

    Is it something I should be checking for in the umbraco admin? does it need it's own datatype or macro/xlst?

    I've got a datatype with macro already in called "relatedlinkslist.xlst" it's just the standard one.

    Many thanks for any help!

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 29, 2011 @ 18:02
    Dennis Aaen
    0

    Hi Pete,

    If I understand your question correctly, you try to point the link to the page specified in umbracoUrlAlias alias. For example / index.aspx. So the link goes to index.aspx. Is this correctly understood. If I have tried my way to a solution. Does not have much experience with the old XML schema.

    But the way  I had written the link, so it goes to what is specified in umbracoUrlAlias is like this.

    <xsl:variable name="umbracoUrlAlias" select="$currentPage/data[@alias='umbracoUrlAlias']"/>

    <
    a href="{$umbracoUrlAlias}">

    But as I said, I do not know if I have understand your question correctly. If I have, hope this can help you.

    /Dennis


     

  • Pete 213 posts 285 karma points
    Jul 29, 2011 @ 18:24
    Pete
    0

    Hi Dennis

    Yes that's exactly what I am trying to do. I actually want the "/index.aspx" to redirect to the root of the site.

    But even if I put the property on other document types and the related url to another page, it doesn't work.

    Do you have a code snippet of a choose / when to decide what to do with the url?

    Pete

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 29, 2011 @ 18:37
    Dennis Aaen
    0

    Hi Pete,

    So you want to redirect the index.aspx page to the root of the site is this correctly understood and all others pages must go to their page url. Or do you want, that you can specify any page to go to the root of the site?,

    Hope it's okay I put some questions to clarify

    /Dennis

  • Pete 213 posts 285 karma points
    Jul 29, 2011 @ 18:47
    Pete
    0

    Yes that's correct dennis.

    Pete

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 29, 2011 @ 19:50
    Dennis Aaen
    0

    Hi again Pete,

    It sounds like you have set up the redirection in WebConfig file so /index.aspx go to the site root.
    I have no experience with redirection, so unfortunately I can not help you further, sorry.

    /Dennis

  • Pete 213 posts 285 karma points
    Jul 29, 2011 @ 20:12
    Pete
    0

    Ok no problem dennis. I know exactly how to do urlrewriting in web.config so that's no issue, thanks.

    I still don't understand why I can't get the umbracoUrlAlias working just on a normal page, ie page1.aspx to page2.aspx.

    Pete

  • webangelo 107 posts 190 karma points
    Jul 29, 2011 @ 20:42
    webangelo
    0

    Hey Pete,

    Although umbracoUrlAlias has a particular purpose of allowing alternate URLs to point to the same page, it should be accessible using the same method as any other data element on a node. However, I don't believe it actually stores the full URL, just the meaty parts.  See this wiki article.  So you'll have to build the URL and the way you build it will be different depending on whether you have .aspx extensions turned on or off.  Also keep in mind that the umbracoUrlAlias allows multiple entries and if you are using that feature, you will need to parse the string further.

    From your syntax I assume you are working in a pre 4.5 version of Umbraco.  The following should work, assuming you are only including one alias.

    No Extensions:

    <a href="/{./data[@alias='umbracoUrlAlias']}">

    Extensions:

    <a href="/{./data[@alias='umbracoUrlAlias']}.aspx">

    I don't currently have anything set up to test pre 4.5 syntax, however this should get you close.

    --Chris

  • Pete 213 posts 285 karma points
    Jul 31, 2011 @ 00:33
    Pete
    0

    Thanks for the extra info chris, that code snippet did the trick.

    I've upgraded to 4.7 so I guess that's why <a href="{data[@alias='umbracoUrlAlias']}"> did'nt work? Maybe I should read release notes for syntax changes.

    Both;

    <a href="/{./data[@alias='umbracoUrlAlias']}">

    and

    <a href="/{./data[@alias='umbracoUrlAlias']}.aspx">

    Worked no probs.

    Pete

  • webangelo 107 posts 190 karma points
    Aug 01, 2011 @ 16:13
    webangelo
    0

    Glad to hear its working for you.

    One thing to note, if you are on 4.7, you must still be using the legacy schema for those to work (an option in your umbracoSettings.config). I would recommend keeping that setting if it is working for you since changing it at this point may invalidate some of your XSLT code.

    If you are using the new schema, simply referencing the name of the property instead of the data[@alias=...] syntax should work.  One thing you will note is that I included a reference to the current node (using the ./ syntax) which you didn't have in your example.  That is likely the critical difference.

    Anyway, if that solved it for you go ahead and mark the solution so others can find it easily if they are having a similar issue.

    --Chris

Please Sign in or register to post replies

Write your reply to:

Draft