Page list - containing folder as headline. how to write this macro
hey there.
im new to xslt - as in i dont get it at all.
and i need to have a macro that writes out my nodes very specifically.
my structure is as such.
Default Page Info Page (just info) Building Page (page that shows all the info below listed out nicely) Area Code 1 (folder to contain the various buildings - just a headline on building page) Buidling one (page with building info - Link to this page on building page) Building two (same) Building three (same) Area Code 2 (etc.etc.) Building four Building Five
so when you click on the website to the Building page - you see this list on the page.
Area Code 1 (headline)
Building One (link) Building Two (link) Building Three (link)
Area Code 2 (headline)
Building Four (link) Building Five (link)
i have been trying to tinker with the various default macros and searched for sumthing like this - but have been unable to do so,
i hope someone can give a good example of this how the macro would look like.
This shouldn't be such complicated: this will be some nested lists with startpoint at a defined level ($currentPage/@level). Take a look into the sitemap xslt template. If you have different documenttypes you can call own subtemplates to output what you want depending on the node where you are.
If you need more help please tell me from which doctyoes the nodes are.
this page has struture set to allow the (headline) page to be place into it. also here the macro would be place in the template. that would list all (headline) / (link)
(headline)
i have a empty document type for the (headline). was thinking that in the xslt ill just remove the <a href></a> so that it doesent go anywhere.
only thing on the (headline) is that in structure i have allowed the (link) document type to be added to it.
(link)
The building document type has building info - and will also contain further links to that specific building. they are not to be shown on the (Buildingpage).
<xsl:template match="/"> <xsl:choose> <xsl:when test="$currentPage/@level = 2"> <!-- I am at level 2 of the hierachy => I am at the Building Page --> <xsl:call-template name="WriteAreas"> <xsl:with-param name="actualNode" select="$currentPage"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="$currentPage/@level = 3"> <!-- I am at level 3 of the hierachy => I am at an Area Page --> <xsl:call-template name="WriteBuildings"> <xsl:with-param name="actualArea" select="$currentPage"></xsl:with-param> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template>
<xsl:template name="WriteAreas"> <xsl:param name="actualNode"></xsl:param> <ul> <xsl:for-each select="$actualNode/node"> <li> <xsl:value-of select="@nodeName" /> <!-- this writes the all AreaCodes --> <xsl:call-template name="WriteBuildings"> <xsl:with-param name="actualArea"></xsl:with-param> </xsl:call-template> </li> </xsl:for-each> </ul> </xsl:template>
unfortunately it lists all buildings in each folder. instead of each individuells folders content.
Folder 1 building 1 right building 2 right building 3 right building 4 wrong building 5 wrong Folder 2 building 1 wrong
building 2 wrong
building 3 wrong
building 4 right
building 5 right
(which is of course because i dont know how to tell it to run through each folder and its child node and then onto the next. )
<xsl:when test="$currentPage/@level = 3"> <!-- I am at level 3 of the hierachy => I am at an Area Page --> <xsl:call-template name="WriteBuildings"> <xsl:with-param name="actualArea" select="$currentPage"></xsl:with-param> </xsl:call-template> </xsl:when>
also dont think i need this if you click the building link - it will open that template and show the building info
<!-- Input the documenttype you want here --> <xsl:variable name="documentTypeAlias" select="string('PostNummer')"/> <xsl:variable name="documentTypeAlias2" select="string('BoligInfo')"/>
<xsl:template match="/">
<!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> <xsl:for-each select="$currentPage/node/node [@nodeTypeAlias = $documentTypeAlias2 and string(data [@alias='umbracoNaviHide']) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </xsl:for-each> </ul>
</xsl:template>
cant this be altered somehow ? . so that it only shows each "postnummer (areacode) and its children boliginfo (buildings) and then shows the next Postnummer+children.
<!-- i change this to only include currentpage which seemed to do what i whant --> <xsl:with-param name="parent" select="$currentPage"/> </xsl:call-template> </div> </xsl:template>
Page list - containing folder as headline. how to write this macro
hey there.
im new to xslt - as in i dont get it at all.
and i need to have a macro that writes out my nodes very specifically.
my structure is as such.
Default Page
Info Page (just info)
Building Page (page that shows all the info below listed out nicely)
Area Code 1 (folder to contain the various buildings - just a headline on building page)
Buidling one (page with building info - Link to this page on building page)
Building two (same)
Building three (same)
Area Code 2 (etc.etc.)
Building four
Building Five
so when you click on the website to the Building page - you see this list on the page.
Area Code 1 (headline)
Building One (link)
Building Two (link)
Building Three (link)
Area Code 2 (headline)
Building Four (link)
Building Five (link)
i have been trying to tinker with the various default macros and searched for sumthing like this - but have been unable to do so,
i hope someone can give a good example of this how the macro would look like.
This shouldn't be such complicated: this will be some nested lists with startpoint at a defined level ($currentPage/@level). Take a look into the sitemap xslt template. If you have different documenttypes you can call own subtemplates to output what you want depending on the node where you are.
If you need more help please tell me from which doctyoes the nodes are.
Thomas
(Buildingpage)
this page has struture set to allow the (headline) page to be place into it.
also here the macro would be place in the template. that would list all (headline) / (link)
(headline)
i have a empty document type for the (headline). was thinking that in the xslt ill just remove the <a href></a> so that it doesent go anywhere.
only thing on the (headline) is that in structure i have allowed the (link) document type to be added to it.
(link)
The building document type has building info - and will also contain further links to that specific building. they are not to be shown on the (Buildingpage).
atleast thats how i was thinking of doing it.
ive been trying to look at that Sitemap macro.
but i cant make heads or tails of it.
i wanna limit that macro to my current page (and only that page) not showing anything else but the current page and its children.
but how to write it im at a loss. - trying to look at some turtorials hoping that ill get a greater understanding of it.
I will do an example for you this morning, have to do some prio work first (about 2 h)
Thomas
thank you! :D
im continuing to look through some turtorials hopefully getting it before.
prio work slipped to the afternoon due to other requirements that have to be defined.
So the following xslt you can place into the Building Template and the Areas template
For learning xslt in umbraco take a look at Doug's blog: http://blog.percipientstudios.com/ especially the two blogentries http://blog.percipientstudios.com/2009/4/11/anatomy-of-an-umbraco-xslt-file.aspx and http://blog.percipientstudios.com/2009/5/5/your-first-umbraco-xslt-macro.aspx
hth, Thomas
this is what ive come up with so far.
<xsl:template match="/">
<ul>
<xsl:for-each select="$currentPage/node">
<li>
<xsl:value-of select="@nodeName"/>
</li>
<ul>
<xsl:for-each select="$currentPage/node/node">
<li>
<xsl:value-of select="current()/@nodeName"/><br />
</li>
</xsl:for-each>
</ul>
</xsl:for-each>
</ul>
</xsl:template>
unfortunately it lists all buildings in each folder. instead of each individuells folders content.
Folder 1
building 1 right
building 2 right
building 3 right
building 4 wrong
building 5 wrong
Folder 2
building 1 wrong
building 2 wrong
building 3 wrong
building 4 right
building 5 right
(which is of course because i dont know how to tell it to run through each folder and its child node and then onto the next. )
oh diddent see you had posted sumthing! (no update)
ill look at it right away!
Thank you!
unfortunately it diddent work. and only error im getting is that
Error parsing XSLT file: \xslt\test2.xslt on my page
think its because my explaination of how the structure is setup.
Content
Website
Building list <- macro (current page)
Area code 1(not visitable) (level 2 ??? - writeareas)
building 1(link) (level 3 ??? - writebuildings)
building 2(link) (level 3 ??? - writebuildings)
Area code 2(not visitable) (level 2 ??? - writeareas)
building 3(link) (level 3 ??? - write buildings)
i hope im making sense - ill look at those blog links too.
ive tried to take it apart bit by bit - and it only lists "anything" when i remove the Write buildings
and then lists area codes - but when i add the bits with write buildings it cant parse it.
not sure whats wrong :(
<xsl:when test="$currentPage/@level = 3">
<!-- I am at level 3 of the hierachy => I am at an Area Page -->
<xsl:call-template name="WriteBuildings">
<xsl:with-param name="actualArea" select="$currentPage"></xsl:with-param>
</xsl:call-template>
</xsl:when>
also dont think i need this if you click the building link - it will open that template and show the building info
Can I get access to the umbraco installation so that I have a look into it at the noon? If so mail me the credentials to "th |at| thoehler |dot| com"
Thomas
unfortunately i dont have it staged atm - its on my local machine only atm.
<xsl:param name="currentPage"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="documentTypeAlias" select="string('PostNummer')"/>
<xsl:variable name="documentTypeAlias2" select="string('BoligInfo')"/>
<xsl:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
<xsl:for-each select="$currentPage/node/node [@nodeTypeAlias = $documentTypeAlias2 and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</xsl:for-each>
</ul>
</xsl:template>
cant this be altered somehow ? . so that it only shows each "postnummer (areacode) and its children boliginfo (buildings) and then shows the next Postnummer+children.
i sorry if i cant describe it better,
newbieness is swarming me at the moment.
dont know if this helps - but did screen shot of my folder structure on umbraco.
http://i24.photobucket.com/albums/c48/redwind85/UmbracoLevel.jpg
Ok i have a solution. after going through a turtorial about xpath disasembled the sitemap macro
after alot of testing tinkering - and luck <---
i found what i was looking for.
<xsl:param name="currentPage"/>
<!-- have to set this at 4 or it wont show anything -->
<xsl:variable name="maxLevelForSitemap" select="4"/>
<xsl:template match="/">
<div id="sitemap">
<xsl:call-template name="drawNodes">
<!-- i change this to only include currentpage which seemed to do what i whant -->
<xsl:with-param name="parent" select="$currentPage"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<ul>
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
i would like to remove the maxlevelforsitemap part of this - just to clean it up alittle. but this works perfectly.
would there be anything bad about doing it this way ?. or is there a way to simplify this more ?. (removing the maxlevelforsitemap)
i needed to control my document types so i added these.
<xsl:variable name="documentTypeAlias" select="string('PostNummer')"/>
<xsl:variable name="documentTypeAlias2" select="string('BoligInfo')"/>
then i added these IF to the For each sentence to elliminate the <a href></a> to the (postnummer) as they where showing as links
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]">
<li>
<xsl:if test="@nodeTypeAlias = $documentTypeAlias">
<xsl:value-of select="@nodeName"/>
</xsl:if>
<xsl:if test="@nodeTypeAlias = $documentTypeAlias2">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</xsl:if>
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
Hi Jan,
Take a look at this way of doing it, starting from scratch - based on the image you posted above:
Feel free to ask, if the inline comments aren't sufficient in explaining what goes on.
/Chriztian
is working on a reply...