Copied to clipboard

Flag this post as spam?

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


  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 12:43
    Ewan Duthie
    0

    XLST Basic Navigation

    Hi,

    New to Umbraco and having a lot of fun getting to grips with it - so far it looks like a great system!

    I'm having some difficulty getting a basic navigation to display though. I followed the video here;

    http://umbraco.tv/documentation/videos/for-site-builders/foundation/creating-your-first-xslt-macro

    however when I insert the Macro into my template, save, the source code just displays </ul> - and doesn't output the list items.

    I've got just three pages in the site tree.

    I'm running Umbraco v4 locally using Cassini web server.

    Sorry for being a bit vague - let me know if any other information is required!

    thanks

    Ewan

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Mar 23, 2010 @ 12:55
    Nik Wahlberg
    0

    Hi Ewan, can you post the contents of your XSLT? Also, are your nodes directly under the 'Content' (aka root) node? 

    Thanks,
    Nik

  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 12:59
    Ewan Duthie
    0

    Hi Nik,

    I'll post the contents this evening (I'm at work and am working on it at home)

    Yes, the nodes are directly under Content.

    thanks

    Ewan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 23, 2010 @ 13:02
    Jan Skovgaard
    0

    Hi Ewan

    Have you tried using the pre-made XSLT file for navigation, which can be selected in the dropdown when you create a new XSLT file in Umbraco? Maybe this can help you out too.

    /Jan

  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 13:08
    Ewan Duthie
    0

    Hi Jan,

    yep, I'm pretty sure I did that. I think that's what the video instructed.

    I'll set up Umbraco here in the office on my lunch break today and go through the process again.

    thanks

    Ewan

  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 20:34
    Ewan Duthie
    0

    Hi Guys,

    here is the contents of my xlst file;

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    
    <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="/">
    
    <!-- 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>

     

    thanks

    Ewan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 23, 2010 @ 21:29
    Jan Skovgaard
    0

    Hi Ewan

    The reason why you don't get any pages in your output is probably that there are no nodes under the $currentPage node.

    I really should have caught this issue when reading your post the first time. But if I understand correctly you have three pages directly under "content", which are at the same level, right?

    So your current content structure looks something like this

    Content
     - node
     - node
     - node

    But for this navigation macro to work you need to have a structure like this

    Content
     - Root node
       - Subnode
       - Subnode
       - Subnode

    Then the three subnodes will occur in the navigation.

    I hope this helps

    /Jan

  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 21:34
    Ewan Duthie
    0

    HI Jan, thanks very much for your help. I should have probably noted in my original post that it was likely something to do with my setup.

    Excuse the newbie question, but how do I now create the Root node and move all my created nodes under this one?

    thanks

    Ewan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 23, 2010 @ 21:53
    Jan Skovgaard
    1

    Hi Ewan

    That's allright - you have to start off from somewhere and that's why we are here to help each other out :-)

    Well I'm asuming you have made at least one document type under the "settings" section. On the document type there is a "structure" tab, where you can choose, which document types are allowed to create under the current one. So if you want to be able to make a structure like the one I have proposed to you then make sure it's allowed to create the document type under itself.

    Then you can create at node you call "Home" and under that one you can create your subpages etc.

    I hope it all makes sense.

    Since you are new to Umbraco I can also recommend that you have a look at the Creative Website Starter package, created by Warren Buckley. It installs a complete site in your Umbraco solution where you can get a lot of inspiration on how to do things in Umbraco.

    A simpler package that can also be great for learning Umbraco is the "Runway package".

    Both packages can be installed from the "developer" section where you can find the "CWS" package in the package repository under "starter kits". Runway can be installed by choosing "install runway".

    Have fun!

    /Jan

  • Ewan Duthie 12 posts 32 karma points
    Mar 23, 2010 @ 22:08
    Ewan Duthie
    0

    Hi Jan

    that seems to have done it. Many thanks again.

    Yes, I have the CWS package installed at work but not at home. I'm trying to simply learn the templating side at the moment from the ground up as most of what I do is front-end development :) 

    cheers

    Ewan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 23, 2010 @ 22:09
    Jan Skovgaard
    0

    Glad it helped! :-)

    Well, the CWS is a great package to learn the frontend-stuff from. There are many usefull XSLT snippets in there.

Please Sign in or register to post replies

Write your reply to:

Draft