Copied to clipboard

Flag this post as spam?

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


  • TomLeads 20 posts 42 karma points
    Feb 04, 2011 @ 10:00
    TomLeads
    0

    URL question

    Hello. More noob questions from me :)

    I use a Content Picker document type to choose a link which is assigned to an image. The link works locally, the url is something like: domain.local/1234

    the database on the development site is the same, but the links don't work. If I change the link, using the content picker, directly on dev, it works fine. Frustrating.

    so first of all, what gives?

    second of all, why is the url the id of the page? Every other link throughout the site is like: about-us.aspx

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 04, 2011 @ 11:49
    Jan Skovgaard
    0

    Hi Tom

    There can very easily be differences on the node id's from dev to live versions. On the inititial deploy they are the same, if you deploy using a dump of the database. But from there the numeration is hard to control dependent on your setup and where content is created etc.

    You can't rely on id's being the same in different versions of your site.

    When you're using the content picker it returns an id. So in order to get a nice url shown you should use some XSLT for instance and call the umbraco.library:NiceUrl and feed it with the id from the content picker...

    It could look something like this:

    <a href="{umbraco.library:NiceUrl($currentPage/yourcontentpickeralias)}">Your page</a>

    Please note that this example is based on the new schema.

    If you're running an earlier version of Umbraco (before 4.5 was released) the syntax looks like this

    <a href="{umbraco.library:NiceUrl($currentPage/data [@alias ='yourcontentpickeralias'])}">Your page</a>

    I hope this makes sense to you?

    /Jan

  • TomLeads 20 posts 42 karma points
    Feb 09, 2011 @ 16:28
    TomLeads
    0

    Hi.

    I fixed this using an XLST macro, rather than in the masterpages themselves (we had to do some other things with XLST for that section anyway)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 14, 2011 @ 19:32
    Jan Skovgaard
    0

    Hi Tom

    Happy to see that you got this fixed...I'm just wondering if you by accident was using the preview mode...somehow got it triggered on the root node?

    EDIT: Obviously I was not thinking clearly here...I guess you fetched the value by using the umbraco:item in the template? Then it makes perfect sense that you only get the id returned.

    /Jan

  • Jon T 18 posts 38 karma points
    Feb 15, 2011 @ 19:19
    Jon T
    0

    I'm having the same problem.   It's generating the page ID instead of using just "default.aspx" or a real index page.   How can I fix this?   My code in the XSLT file is below:

             <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                 <xsl:attribute name="class">home current</xsl:attribute>
             </xsl:if>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 15, 2011 @ 21:24
    Jan Skovgaard
    0

    Hi Jon

    I'm not sure you have managed to post all your code? The above sample looks like you're trying to add a current class if a condition is met?

    Please post the whole code that you're struggling with and it will be more easy to point you in the right direction :-)

    /Jan

  • Jon T 18 posts 38 karma points
    Feb 15, 2011 @ 21:29
    Jon T
    0

    Sorry, Jan.  Here's my umbTopNavigation.xslt code:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      exclude-result-prefixes="msxml umbraco.library">


        <xsl:output method="xml" omit-xml-declaration="yes" />

        <xsl:param name="currentPage"/>

        <!-- Input the documenttype you want here -->
        <xsl:variable name="level" select="1"/>

        <xsl:template match="/">

         
     <ul id="topNavigation">
           <li class="home">
             <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                 <xsl:attribute name="class">home current</xsl:attribute>
             </xsl:if>
             <a href="/">Home</a>
           </li>
          <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
         <xsl:if test="@id = $currentPage/@id">
            <xsl:attribute name="class">current</xsl:attribute>
          </xsl:if>
        <a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
          <span><xsl:value-of select="@nodeName"/></span>
        </a>
      </li>
     
     
    </xsl:for-each>
    </ul>

        </xsl:template>

    </xsl:stylesheet>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 15, 2011 @ 21:39
    Jan Skovgaard
    0

    Hi Jon

    Is it a version 4.6.1 you experience this on?

    What happens if you try to use the "navigation prototype" out of the box, which can be selected from the dropdown list when one creates an XSLT based macro in the developer section?

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft