<!-- The fun starts here --> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <div class="specialoffer" style="padding-left:10px;"> <div style="width:220px;float:left;width:220px;"> <xsl:value-of select="offerImage" disable-output-escaping="yes"/> </div> <div class="specialofferbody" style="float:right;width:420px;"> <h2 class="specialoffer"><xsl:value-of select="offerTitle" disable-output-escaping="yes"/></h2> <xsl:value-of select="offerSummary" disable-output-escaping="yes"/> <a href="contact-us.aspx" class="bluebutton">Offer Enquiry</a> </div> </div> </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Can someone please show me how to pull the offers title and the offers summary to my homepage, and if you're feeling extra generous please explain roughly how you achieved this?
Also, if I have left out any vital info please ask and ye shall receive.
Would'nt you be able to use exactly the same code?
If the pages you want to list on your homepage are children of it, then you should be able to use the above code to list them unless I'm missing something?
thanks for the quick response. I'm afraid it doesn't work. The homepage is on the same level as the Offers page right now, and the offers themselves are children of the Offers page. This is because I have a holding page on the top level. I tried adding the macro to the holding page, whereby the Offers page is a child, but it goes screwy! (makes multiple scrolling divs with no content).
Ok, so if I understand you correctly it's actually not content from subpages under your homepage node you want to have displayed. But content from other nodes at the same level as the homepage node?
In that case you can use the GetXmlNodeById extension from the umbraco.library.
<xsl:variable name="contentSrc" select="umbraco.library:GetXmlNodeById(yourid)" /> - you can find the id of a node by focusing a node and look at the bottom left corner.
You can now use the $contentSrc variable in your for-each loop to get the content.
If you don't want to hardcode the id you can add a content picker to your homepage documet type, in which you can choose the node where you want the subnodes from.
Then the variable could look something like this <xsl:variable name="contentSrc" select="umbraco.library:GetXmlNodeById($currentPage/YourPropertyName)" />
Currently, My two special offers are child pages of the Special Offers page. When I added the macro to the homepage template, it did not find the required offers. BUT, when I copied the child pages (the offers) to directly below the homepage, the exact same XSTL worked. This leads me to believe that the XSLT only works for child pages directly below the page the macro is used on.
The following sitemap didn't work:-
Home Special offers - Offer 1 - Offer 2
the following sitemap did work:-
Home - offer 1 - offer 2 Special Offers - offer 1 - offer 2
This means I just need to figure out how to make an xslt file that can target child pages of another node or level. Does this make sense? I hope so!
List sub pages from homepage - hopefully quick fix.
Hi Folks,
I have a quick question to ask that I hope will be easy for you guru's out there.
I currently have this xslt (successfully) pulling offers image, offers title and offers summary from pages directly below it.
Can someone please show me how to pull the offers title and the offers summary to my homepage, and if you're feeling extra generous please explain roughly how you achieved this?
Also, if I have left out any vital info please ask and ye shall receive.
Hi David
Would'nt you be able to use exactly the same code?
If the pages you want to list on your homepage are children of it, then you should be able to use the above code to list them unless I'm missing something?
/Jan
Hi Jan,
thanks for the quick response. I'm afraid it doesn't work. The homepage is on the same level as the Offers page right now, and the offers themselves are children of the Offers page. This is because I have a holding page on the top level. I tried adding the macro to the holding page, whereby the Offers page is a child, but it goes screwy! (makes multiple scrolling divs with no content).
Thanks for trying!
David.
Ok, so if I understand you correctly it's actually not content from subpages under your homepage node you want to have displayed. But content from other nodes at the same level as the homepage node?
In that case you can use the GetXmlNodeById extension from the umbraco.library.
<xsl:variable name="contentSrc" select="umbraco.library:GetXmlNodeById(yourid)" /> - you can find the id of a node by focusing a node and look at the bottom left corner.
You can now use the $contentSrc variable in your for-each loop to get the content.
If you don't want to hardcode the id you can add a content picker to your homepage documet type, in which you can choose the node where you want the subnodes from.
Then the variable could look something like this <xsl:variable name="contentSrc" select="umbraco.library:GetXmlNodeById($currentPage/YourPropertyName)" />
Hope this helps
/Jan
Hi Jan, I spotted something.
Currently, My two special offers are child pages of the Special Offers page. When I added the macro to the homepage template, it did not find the required offers. BUT, when I copied the child pages (the offers) to directly below the homepage, the exact same XSTL worked. This leads me to believe that the XSLT only works for child pages directly below the page the macro is used on.
The following sitemap didn't work:-
Home
Special offers
- Offer 1
- Offer 2
the following sitemap did work:-
Home
- offer 1
- offer 2
Special Offers
- offer 1
- offer 2
This means I just need to figure out how to make an xslt file that can target child pages of another node or level. Does this make sense? I hope so!
Hi Jan,
sorry I must have replied while you were typing your response. Thanks for your solution, I will try my best to implement it now.
Many thanks,
David.
Hi Jan,
Below is my best attempt at implementing your solution. Suffice to say it does not work. Please point out where I am going wrong.
Hi David
In the above example you are just writing $contentSrc in your select statement in the for-each...
You need all the other exciting stuff as you also have in the previous sample you posted
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
So now you just need to replace $currentPage with $contentSrc since this is now your starting point. So it should look like this
<xsl:for-each select="$contentSrc/* [@isDoc and string(umbracoNaviHide) != '1']">
try giving it a go.
A minor tip...
to see what XML is returned in your variable you can make a textarea and do a copy-of. You can do it like this
<textarea>
<xsl:copy-of select="$contentSrc" />
</textarea>
It makes it a lot easier to figure out, which elements to match etc.
/Jan
Hi Jan,
That was really simple in the end. Thanks for the help!!
This info will be really useful in the long run.
David.
is working on a reply...