I can't display level 0? Options
mikkelstrack
Posted: Monday, May 26, 2008 4:05:12 PM
Rank: Newbie

Joined: 3/25/2008
Posts: 11
Hi,

I have a site-structure like this
-frontpage
--subpage 1
--subpage 2

Im creating a menu doing something like this
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">

If level = 1, I get the expected...subpage 1 and 2
If level = 0, I get nothing?

What am I doing wrong?
Dirk
Posted: Monday, May 26, 2008 7:19:13 PM

Rank: Fanatic

Joined: 9/27/2007
Posts: 465
Location: Belgium
Quote:
What am I doing wrong?


In fact, nothing. Frontpage will get level = 1 and there will not be a node at level = 0.
Have a look at your db if you can, and exec this query

Code:
SELECT [nodeId], [xml]
  FROM [dbo].[cmsContentXml]


Regards,
/Dirk


level 1 certified - umbraco blog at netaddicts.be
Hendy Racher
Posted: Monday, May 26, 2008 7:54:53 PM
Rank: Newbie

Joined: 7/5/2007
Posts: 21
Hi,

As recommended on another post, I found SketchPath 2.0 in conjunction with an XML dump of the Umbraco content to be really helpful for understanding and checking the XSLT.

To get the XML I use a 'debug' macro which just returns :
Code:

<xsl:copy-of select="umbraco.library:GetXmlAll()" />


Although I believe the Umbraco.config file in the \data folder contains the same information.

To get all nodes at -fontpage level, it's just :

Code:

/root/node


and to get them via the $currrentPage parameter it's :

Code:

$currentPage/ancestor::root/node


HTH,
Hendy.
mikkelstrack
Posted: Thursday, May 29, 2008 11:13:42 AM
Rank: Newbie

Joined: 3/25/2008
Posts: 11
Thanks for replies :)

Im not sure I ended up with the best solution, but I just did two for-each

Frontpage
<xsl:for-each select="$currentPage/ancestor-or-self::root/node [string(data [@alias='umbracoNaviHide']) != '1']">

All others
<xsl:for-each select="$currentPage/ancestor-or-self::node[@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">


Not that good looking, but it works :)
pgfearo
Posted: Friday, May 30, 2008 10:38:50 AM
Rank: Newbie

Joined: 5/30/2008
Posts: 1
Location: UK
Good to see SketchPath is being found helpful.

Just a quick tip:

When you use: node != 'b' in XPath its unlikely that this will give you want you want in all cases. This is down to the 'existential quantifier' in XPath. If you're looking to achieve the opposite of node = 'b' , use not(node = 'b') instead.

A fuller explantation is at:

http://www.w3.org/XML/2003/11/xpath-xquery-issues/#xquery-xpath-existential

Dirk
Posted: Friday, May 30, 2008 12:18:12 PM

Rank: Fanatic

Joined: 9/27/2007
Posts: 465
Location: Belgium
Oh yes pgfearo, your tool is a real timesaver for non-xslt guru's. Many thanks for sharing.
I've 'sent' already a lot of people to your site to grab the tool.
Again, thanks for the effort.

Regards,
/Dirk


level 1 certified - umbraco blog at netaddicts.be
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.