|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
Hi I'm green like a new born baby I have a content like  and I like on Starting page to show link of all books ? How? I rely don't know anything ..some tips or some example will be great
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,831 Location: MA, USA
|
Here's how I'd start... In the Developer section of umbraco, right-click on the XSLT item and create a new xslt macro. In the dialog box, select the "list subpages from changable source" and put a checkmark in the "create macro" checkbox. Give it a name such as "List Books" and click OK. Now go to the Macros item in the Developer section of umbraco and expand it to find the "List Books" macro. Put a checkmark in the 'use in editor' checkbox. On the Parameters tab, add the following... - Place a checkmark in the Show box; - Type 'source' (lowercase, no quotes) in the Alias field; - Type 'Select the folder containing Books' in the Name field; - Select the 'ContentPicker' Type - click Add button That's it! Your macro is ready to use and will give you a UL/LI list of all the nodes directly beneath the 'source' node you select. On your Starting Page, insert the List Books macro and select the 'books' node as the source. Publish the page and view in the browser. You can use CSS to style the output. To change the output just edit the xslt file. cheers, doug.
MVP 2007-2009 - Percipient Studios
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
Hi I did everythning that you told me but when I whant to save / publish page I get a error Code: Length cannot be less than zero. Parameter name: length Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length
What is wrong ??
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
I change the XSLT like Quote: <xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="BookNodeId" select="/macro/nodeId"/>
<!-- start writing XSLT --> <xsl:template match="/"> <xsl:call-template name="menu"> </xsl:call-template> </xsl:template>
<xsl:template name="menu"> foo <xsl:for-each select="umbraco.library:GetXmlNodeById($BookNodeId)/node"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </xsl:for-each> </xsl:template>
<xsl:template name="menu2"> foo22 <xsl:for-each select="$currentPage/ancestor::root/node[@nodeName='books']"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </xsl:for-each> </xsl:template>
and when I use menu2 I get only books link and when I use menu template I get nothing HELP
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
I get it ... the problem is that I don't publish all books child nodes
thanks for everythning
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
I'm still facing with problem ... according to my content (see picture on top) I want navigation like this .. Book1 Chapter1 Page1 Page2 Page3 .....Page N Chapter2 Page1 Page2 Page3 ....Page N Book2 .... I have some XSLT like this Quote: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <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"/>
<xsl:variable name="BookNodeId" select="/macro/nodeId"/>
<!-- start writing XSLT --> <xsl:template match="/"> <xsl:call-template name="menu2"> </xsl:call-template> </xsl:template>
<!-- not used --> <xsl:template name="menu">
<xsl:for-each select="umbraco.library:GetXmlNodeById($BookNodeId)/node"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </xsl:for-each> </xsl:template>
<xsl:template name="menu2"> <br></br> <xsl:for-each select="$currentPage/parent::root/node[@nodeName='books']/node"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> <xsl:call-template name="menu3"> </xsl:call-template> </xsl:for-each> </xsl:template>
<xsl:template name="menu3"> <br></br> <xsl:for-each select="$currentPage/ancestor [string(./data [@alias='umbracoNaviHide']) != '1']">
<a href="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute> <xsl:value-of select="@nodeName" /> </a> </xsl:for-each> </xsl:template>
</xsl:stylesheet>
and all I got is Book1 Book2 HELP
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,136 Location: Belgium
|
Hi, I'm not a xslt guru either, but I'm guessing that your menu3 template should be changed. Menu2 template is iterating all childs of a node called with @nodeName='books' (Retrieves thus all 'bookX' nodes). In there, you make a call to the menu3 template which iterates all parent nodes for the current node, which is $currentPage. Meaning that if you're on the 'books', you're listing all parent nodes of 'books' node, and there's none. You'll need to change menu3 template to accept the current node you're processing in menu2 template and iterate over the child nodes of the node set as parameter For example: Code:<xsl:template name="menu2"> <br></br> <xsl:for-each select="$currentPage/parent::root/node[@nodeName='books']/node"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> <xsl:call-template name="menu3"> [b]<xsl:with-param name="currentNode" select="."/>[/b] </xsl:call-template> </xsl:for-each> </xsl:template> and Code:<xsl:template name="menu3"> [b]<xsl:param name="currentNode"/>[/b] <br></br> <xsl:for-each select="$currentNode/node [string(./data [@alias='umbracoNaviHide']) != '1']"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute> <xsl:value-of select="@nodeName" /> </a> </xsl:for-each> </xsl:template> I'm writing this in here without any syntax verification... Same technique of passing a parameter to another template can be applied to list all child nodes of the node you're processing in menu3 template (Getting all 'Page' nodes) Hope that helps.
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
hi basicly I have did the similar but in your code I don't see recursion call ? my code Quote: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <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"/>
<xsl:variable name="BookNodeId" select="/macro/nodeId"/>
<!-- start writing XSLT --> <xsl:template match="/"> <xsl:call-template name="menu2"> </xsl:call-template> </xsl:template>
<!-- not used --> <xsl:template name="menu">
<xsl:for-each select="umbraco.library:GetXmlNodeById($BookNodeId)/node"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </xsl:for-each> </xsl:template>
<xsl:template name="menu2"> <br></br> <xsl:for-each select="$currentPage/parent::root/node[@nodeName='books']/node">
<xsl:value-of select="@nodeName"/>
<xsl:call-template name="menu3"> <xsl:with-param name="parent" select="@nodeName"/> </xsl:call-template> </xsl:for-each> </xsl:template>
<xsl:template name="menu3"> <xsl:param name="parent"/> <br></br> <ul> <!-- iterate over all elements of the current level --> <xsl:for-each select="$currentPage/ancestor::root//node[@nodeName=$parent]/node [string(data [@alias='umbracoNaviHide']) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">nav_selected</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName"/> </a>
<!-- test for children, recurse if found --> <xsl:if test="count(descendant::node [string(data [@alias='umbracoNaviHide']) != '1']) > 0"> <xsl:call-template name="menu3"><xsl:with-param name="parent" select="@nodeName"/></xsl:call-template> </xsl:if>
</li> </xsl:for-each> </ul> </xsl:template>
</xsl:stylesheet>
it could be niceer but is works
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,136 Location: Belgium
|
Hi, It's working, great! Doesn't really matter how, as long as it works. Having some remarks as to your parameters. I'm not sure why to pass the node's nodename, rather than passing the complete node! Code:<xsl:call-template name="menu3"> <xsl:with-param name="currentNode" select="."/> </xsl:call-template> And, yes, I wasn't using any recursive call. So did you in your first xslt listing (You've added that recursive call in the last reply). Greetz, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
so basicly I solved my problem ... now I have one more :-)
I would like to on each Page... have a link to next and previous page in the same level... Of course first page don't have previous and last page don't have next link ...
I think I explain what I want, Dirk can you help me ... you are relay good in this XSLT ;-)
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,136 Location: Belgium
|
lpastor wrote:I would like to on each Page... have a link to next and previous page in the same level... Of course first page don't have previous and last page don't have next link ... Xslt has some built-in functions position(), current(), first() and last() you can use for this purpose. Here's an example: Code:<xsl:for-each select="$currentPage/node"> <xsl:if test="position() = first()"> ...no back link </xsl:if> <xsl:if test="position() = last()"> ...no next link </xsl:if> </xsl:for-each> Hope that helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
Dirk you are a great Umraco guru :-)
Yes it will be probably a solution but what should I do if I what that navigation solve in User control???
How can I get next and previous node trough C#?
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,136 Location: Belgium
|
Hi lpastor, It could be done, but, personally, I don't think it's a good idea. Why would you want to have your navigation logic in a user control. Xslt does all you need.µ If you still want to go the user control way, have a look at the umbraco api, although I guess you'll be ending up using the same library functions as you would when using xslt. I haven't done it already, so have no examples available, and will avoid to use it. It's your choice after all, but I would stick to the xslt solution. Greetz, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
|
Guest |