I hope someone can help me with this problem. I have a page where I want to have a div, and inside that div another div which is suppose to run 4 times, like this:
Thanks for your answer, I did find this solution when searching. However I do not understand it totally. I have tryed to change something, but nothing seems to chance on my page. It seems like my situation is a bit different, which may be why I do not understand it.
I have a overview-page, which has x number of children. This overview-page have to get some properties from these childs. Is that how this code works too?
The basis problem is I not understand everything, basicly what is going on on every step. I have only worked with umbraca for 3 weeks now, and this kode snippet is a bit advance for me to understand. This gives me a problem with replacing the right context with my stuff.
eg. this bit:
!-- Grab the data to output -->
<xsl:variable name="nodes">
<xsl:copy-of select="$root//*[@nodeType = 1074][not(umbracoNaviHide = 1)]" />
</xsl:variable>
Does this mean that at the nodeID (Is nodetype = nodeID?) the result are places in a variable?
This I have no idea what does / what it is suppose to achieve?
Then there are 3 parts which is worked around the "apply-template" coding, which I have never work with. I read some stuff about if, but is in generel not sure how it works.
<xsl:template match="/">
<!-- Apply templates to every third document, starting with the first -->
<xsl:apply-templates select="$data/*[position() mod 3 = 1]" mode="row" />
</xsl:template>
<!-- Template to start a row -->
<xsl:template match="*[@nodeType = 1074]" mode="row">
<div class="row">
<!-- Now render this document and the following 2 -->
<xsl:apply-templates select=". | following-sibling::*[@nodeType = 1074][position() < 3]" mode="col" />
</div>
</xsl:template>
<!-- Template for a column -->
<xsl:template match="*[@nodeType = 1074]" mode="col">
<div class="col">
<!-- Redefine class for every third item -->
<xsl:if test="position() mod 3 = 0">
<xsl:attribute name="class">col last</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName" />
</div>
</xsl:template>
Here's something that should work as a sample for you - feel free to ask about the specifics of this one:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="umbraco.library"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
<!--
Grab all the nodes you need to render - you can do this in many ways,
this assumes they are all of the document type Artikel and that they are
children of currentPage:
-->
<xsl:variable name="nodes" select="$currentPage/Artikel[not(umbracoNaviHide = 1)]" />
<!-- How many should be grouped together? -->
<xsl:variable name="groupSize" select="4" />
<xsl:template match="/">
<!-- Apply templates to all the "first" Artikel nodes in each group in "wrapper" mode -->
<xsl:apply-templates select="$nodes[position() mod $groupSize = 1]" mode="wrapper" />
</xsl:template>
<!-- Template to start a group -->
<xsl:template match="Artikel" mode="wrapper">
<div class="product_oversight">
<!-- Now process this Artikel and the following in the same group, in "item" mode -->
<xsl:apply-templates select=". | following-sibling::Artikel[position() < $groupSize]" mode="item" />
</div>
</xsl:template>
<!-- The actual rendering template for an Artikel -->
<xsl:template match="Artikel" mode="item">
<div class="product_brief">
<img src="{oversigtsbilled}" />
<p class="product_title"><xsl:value-of select="oversigtTitle" /></p>
<p><xsl:value-of select="oversigtTeaser"/></p>
<a href="{umbraco.library:NiceUrl(@id)}">Læs mere</a>
</div>
</xsl:template>
</xsl:stylesheet>
Div inside div for every 4 chiild
Hallo everyone,
I hope someone can help me with this problem. I have a page where I want to have a div, and inside that div another div which is suppose to run 4 times, like this:
I have got this so far, but no idea how to finish it off:
I am well aware that this is only running 4 times, but I have no idea how to get the last part to work.
Help pls! Thanks in advance.
See Toms or Chriztians post here http://our.umbraco.org/forum/developers/xslt/12819-Adding-div-around-every-3rd-item-returned-from-GetXmlAll()
Hi Matias,
I search the forum for similar posts on the subject.
And I think you can find inspiration or use Chriztian Steinmeier answers.Chriztian is really good at XSLT.
http://our.umbraco.org/forum/developers/xslt/11527-Problem-with-listing-HTLM-strcuture-with-XSLT
Hope it can help you out.
/Dennis
Hallo both of you,
Thanks for your answer, I did find this solution when searching. However I do not understand it totally. I have tryed to change something, but nothing seems to chance on my page. It seems like my situation is a bit different, which may be why I do not understand it.
I have a overview-page, which has x number of children. This overview-page have to get some properties from these childs. Is that how this code works too?
Hey Matias,
You have to let us know which bit you're having problems with.
The solution we posted a link to show's you how to determine when to open / close DIV's so you can have every 4th one closed.
Listing the children is a different question.
However to answer your question, the answers we linked to are generic.
Rich
Hi Matias,
I think you need to show us the actual output you want, e.g., is it something like this: ?
/Chriztian
The basis problem is I not understand everything, basicly what is going on on every step. I have only worked with umbraca for 3 weeks now, and this kode snippet is a bit advance for me to understand. This gives me a problem with replacing the right context with my stuff.
eg. this bit:
Does this mean that at the nodeID (Is nodetype = nodeID?) the result are places in a variable?
This I have no idea what does / what it is suppose to achieve?
Then there are 3 parts which is worked around the "apply-template" coding, which I have never work with. I read some stuff about if, but is in generel not sure how it works.
Hi Christian,
My Content section looks like this:
Inside each artikel, there are some parameter which I would like to take out and use in the template for product.
You are right my ending html is suppose to look like this.
<divclass="product_oversight">
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
</div>
<divclass="product_oversight">
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
<divclass="product_brief">...</div>
</div>
Inside each <div class="product_brief">
Hi Matias,
Here's something that should work as a sample for you - feel free to ask about the specifics of this one:
/Chriztian
Thanks Chriztian!
It works like a charm and I think I understood most of it too. Very nice comment and understanding code!
is working on a reply...