Copied to clipboard

Flag this post as spam?

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


  • Dany Wu 81 posts 114 karma points
    Jul 10, 2009 @ 13:03
    Dany Wu
    0

    Listing SubPages pages at a certain level

    Hi folks,

    I am trying to create a simple top level menu based on the "List Sub Pages By Level" XSLT. Unfortunately I simply can't get it to work the way I wanted.

    Here's my site structure as displayed in the Content section:

    Content
        Page 1
            Page 1.1
            Page 1.2
        Page 2
        Page 3
            Page 3.1
            Page 3.2

    ...and so forth. Basically I want a vertical menu to show:

    Page 1
    Page 2
    Page 3

    I can cheat this by shifting every page one level deeper and display the menu starting from the the new "top level" node immediately below "Content". Unfortunately this doesn't work with the Breadcrumb macro which uses "/" as the URL for the "Home" item. This also displays the container top level node when someone accesses the site without specifying any page.

    I hope I have explained this clearly. Any suggestions or hints would be greatly appreciated.

    Many thanks,
    Dany.

  • Sjors Pals 617 posts 270 karma points
    Jul 10, 2009 @ 13:16
    Sjors Pals
    0

    You can use the @level attribute, here is a sample:

     

    <?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="2"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 10, 2009 @ 13:17
    Dirk De Grave
    0

    Hi Dany,

     

    "I can cheat this by shifting every page one level deeper and display the menu starting from the the new "top level" node immediately below "Content"."

     

    --> that is how most people structure their site, and it's IMHO umbraco best practice to do so.

     

    "Unfortunately this doesn't work with the Breadcrumb macro which uses "/" as the URL for the "Home" item"

     

    --> Haven't tried that, but don't think it would become a problem

     

    "This also displays the container top level node when someone accesses the site without specifying any page."

     

    --> Add an extra property umbracoRedirectId (type = content picker) to that 'Container top level' node, and select first node ('Page 1'). Doing so will allow to redirect to that page when someone browses to the 'Container' page 

     

     

     

    Hope this helps.

     

    Regards,

     

    /Dirk

  • Dany Wu 81 posts 114 karma points
    Jul 10, 2009 @ 14:18
    Dany Wu
    0

    Hi Dirk,

    Thank you very much for your suggestion. I have done everything but it seems adding a property called umbracoRedirectId did not automatically redirect to the selected page when I use http://site/ URL.

    Is there a step I have missed somewhere?

    Cheers,
    Dany.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 10, 2009 @ 14:27
    Dirk De Grave
    0

    Do you have a page set for the umbracoRedirectId property?

  • Dany Wu 81 posts 114 karma points
    Jul 10, 2009 @ 14:33
    Dany Wu
    0

    Forgot to add that, having seen googled this a little more, I have also tried adding a property called umbracoRedirect of the Content Picker type. This didn't do anything either. Both umbracoRedirectId and umbracoRedirect didn't raise any errors - it simply did not display any page - just blank.

    D.

  • Dany Wu 81 posts 114 karma points
    Jul 10, 2009 @ 14:34
    Dany Wu
    0

    Yup, I have set the property value to the appropriate page.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 10, 2009 @ 14:36
    Dirk De Grave
    0

    It might be a good idea to add some trace output to the page using ?umbdebugshowtrace=true and see if the umbraco request handler picks up anything?

     

  • Dany Wu 81 posts 114 karma points
    Jul 10, 2009 @ 14:47
    Dany Wu
    0

    Great suggestion! As it turns out there was an error saying: "Master template is the same as the current template. It would course an endless loop!". When I created the Document Type for this redirecting page I did not create a matching template!

    What's the best practice here? Do I create a blank template? or can I use some other random template?

  • Dany Wu 81 posts 114 karma points
    Jul 11, 2009 @ 02:09
    Dany Wu
    0

    Ok, this is really baffling me - here's my Template structure:

    Base
        RedirectingPage (only has a blank <asp:content> element)
        SimpleContent (has umbraco fields in the <asp:content> element)

    My DocumentTypes are:

    RedirectingPage (using RedirectingPage template, has the umbracoRedirectId field of Content Picker type)
    SimpleContent (using the SimpleContent template)

    My Content structure looks like:

    RootLevel (of RedirectingPage DocType)
        Page 1 (SimpleContent)
        Page 2 (SimpleContent)

    RootLevel node has its umbracoRedirectId field set to Page 1. It all seems simple and straightforward to me - yet I am still getting the "Master template is the same as the current template..." error. I have republished the whole structure, even re-started IIS, all to no avail. Still the same error.

    I'm utterly stumped on this one - can someone please give me a hint on what I have missed?

    Many thanks,
    Dany.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 11, 2009 @ 10:10
    Dirk De Grave
    0

    Hi Dany,

    Don't think you need a RedirectingPage template to be set on RedirectingPage doc type. Could you switch templates (ie setting no template) for those RedirectingPage documents (it might be a collision of template/redirecting that makes it behave that odd)

     

    Let us know if that works out.

     

    Cheers,

    /Dirk

     

  • Dany Wu 81 posts 114 karma points
    Jul 11, 2009 @ 12:19
    Dany Wu
    0

    Hi again Dirk, I have experimented some more on this. I have unset any template from the RedirectingPage doc type, and even deleted the RedirectingPage template completely. I then republished the whole site but this hasn't made any difference.

    I made another node, so now my Content structure looks like:

    Content
        RootLevel
            Page 1 (SimpleContent type)
            Page 2 (SimpleContent type)
        Test (SimpleContent type)

    If I navigate to http://localhost it correctly forwards to the page-1.aspx URL but then there's the template error again. If I try http://localhost/page-2.aspx there's also the template error. However, if I try http://localhost/test.aspx the page displays correctly! I think you're right - it's something to do with the redirection but I don't know enough about the inner workings of Umbraco to figure this out...

    Cheers,
    D.

  • Dany Wu 81 posts 114 karma points
    Jul 17, 2009 @ 00:08
    Dany Wu
    0

    Strange as it may seem suddenly it all started working! I shut down the dev VM and left it alone for a few days. Last night I returned to it to have another go at it, and it was already working. Strange - perhaps it was some peculiar IIS/Umbraco caching issues that was flushed with the restart? Not sure...

Please Sign in or register to post replies

Write your reply to:

Draft