I'm trying to add some blocks of content to my website that will be inserted into multiple pages. I found this how-to on creating resuable content, and it was pretty close to what I wanted, so I followed it. I set it up exactly as it said, with the same names and IDs, and it's working as intended. It doesn't exactly fit my needs, though, and I could use some help modifying it.
The 'how-to' uses an Ultimate Picker on each back-end page the content will show up on, that requires you to manually select the 'touts' you want to display. I have two pages I want to show the content on: one should list all touts that currently exist, and another should show the newest 5 or so; I don't want to manually manage what shows up with checkboxes.
How would I remove the Ultimate Picker from the setup, so the XSLT inserts all touts without requiring me to mess with checkboxes on the back-end pages? If someone could also help me get it to display a fixed number of items on certain pages, or set up a back-end control for the number of touts to display, even better. Can anyone point me in the right direction?
That code looks promising, but for some reason I can't get it to work. I set up everything as you suggested, and when I go to the page, or do Visualize XSLT, I get no output, regardless of the mode, the page I try to display them on, and how many Touts I have published.
I think I understand what the code is supposed to do, and I broke down the code to try to isolate the issue; my best guess is that something is wrong with the XPath that is being generated to find the Tout nodes. I tried to write some code to display the contents of a single specific tout, but I could never get anything to show up. I'm just learning XPath and XSLT, so hopefully I'm missing something simple?
How would I display the contents of "toutTitle" on any individual tout? Maybe if I could get that to work, I could work backwards and fix the whole thing. Below is the contents of the Touts XML from my umbraco.config file. Any further help would be greatly appreciated.
I can see what 's wrong now - the XSLT assumes your Touts node is below your site's root, but I can see that it's actually at the top level, which means that the touts variable is set to nothing and the rest fails from there.
You should set the touts variable using either of these instead, and it should all just work:
Help modifying an existing XSLT?
I'm trying to add some blocks of content to my website that will be inserted into multiple pages. I found this how-to on creating resuable content, and it was pretty close to what I wanted, so I followed it. I set it up exactly as it said, with the same names and IDs, and it's working as intended. It doesn't exactly fit my needs, though, and I could use some help modifying it.
The 'how-to' uses an Ultimate Picker on each back-end page the content will show up on, that requires you to manually select the 'touts' you want to display. I have two pages I want to show the content on: one should list all touts that currently exist, and another should show the newest 5 or so; I don't want to manually manage what shows up with checkboxes.
How would I remove the Ultimate Picker from the setup, so the XSLT inserts all touts without requiring me to mess with checkboxes on the back-end pages? If someone could also help me get it to display a fixed number of items on certain pages, or set up a back-end control for the number of touts to display, even better. Can anyone point me in the right direction?
Hi David,
I'd wipe everything and start from scratch - the way I see it, you need this:
1. A bunch of "touts" somewhere in a container type in Umbraco (you probably already have this) e.g.:
2. A "Max no. of Touts" (maxNoOfTouts) property on the container document type
3. A single Macro for rendering the Touts
4. A "mode" parameter on the macro
5. XSLT like this in the macro file:
On the page where you need all touts displayed, call the macro like this:
- and on the other pages, to display a fixed number of touts, omit the mode parameter:
Chriztian,
That code looks promising, but for some reason I can't get it to work. I set up everything as you suggested, and when I go to the page, or do Visualize XSLT, I get no output, regardless of the mode, the page I try to display them on, and how many Touts I have published.
I think I understand what the code is supposed to do, and I broke down the code to try to isolate the issue; my best guess is that something is wrong with the XPath that is being generated to find the Tout nodes. I tried to write some code to display the contents of a single specific tout, but I could never get anything to show up. I'm just learning XPath and XSLT, so hopefully I'm missing something simple?
How would I display the contents of "toutTitle" on any individual tout? Maybe if I could get that to work, I could work backwards and fix the whole thing. Below is the contents of the Touts XML from my umbraco.config file. Any further help would be greatly appreciated.
<Touts id="1200" parentID="-1" level="1" writerID="0" creatorID="0" nodeType="1198" template="0" sortOrder="6" createDate="2012-03-07T10:11:00" updateDate="2012-03-07T10:14:10" nodeName="Touts" urlName="touts" writerName="Web" creatorName="Web" path="-1,1200" isDoc="">
<maxNoOfTouts>12</maxNoOfTouts>
<Tout id="1201" parentID="1200" level="2" writerID="0" creatorID="0" nodeType="1199" template="0" sortOrder="1" createDate="2012-03-07T10:11:33" updateDate="2012-03-07T10:11:44" nodeName="Tout 1" urlName="tout-1" writerName="Web" creatorName="Web" path="-1,1200,1201" isDoc="">
<toutTitle>This is text for the first tout.</toutTitle>
</Tout>
<Tout id="1202" parentID="1200" level="2" writerID="0" creatorID="0" nodeType="1199" template="0" sortOrder="2" createDate="2012-03-07T10:11:50" updateDate="2012-03-07T10:11:59" nodeName="Tout 2" urlName="tout-2" writerName="Web" creatorName="Web" path="-1,1200,1202" isDoc="">
<toutTitle>This is text for the second tout.</toutTitle>
</Tout>
<Tout id="1203" parentID="1200" level="2" writerID="0" creatorID="0" nodeType="1199" template="0" sortOrder="3" createDate="2012-03-07T10:12:04" updateDate="2012-03-07T10:12:11" nodeName="Tout 3" urlName="tout-3" writerName="Web" creatorName="Web" path="-1,1200,1203" isDoc="">
<toutTitle>This is text for the third tout.</toutTitle>
</Tout>
<Tout id="1204" parentID="1200" level="2" writerID="0" creatorID="0" nodeType="1199" template="0" sortOrder="4" createDate="2012-03-07T10:12:16" updateDate="2012-03-07T10:12:23" nodeName="Tout 4" urlName="tout-4" writerName="Web" creatorName="Web" path="-1,1200,1204" isDoc="">
<toutTitle>This is text for the fourth tout.</toutTitle>
</Tout>
</Touts>
Hi David,
I can see what 's wrong now - the XSLT assumes your Touts node is below your site's root, but I can see that it's actually at the top level, which means that the touts variable is set to nothing and the rest fails from there.
You should set the touts variable using either of these instead, and it should all just work:
or:
(If you're not using all of my code from above, you may need to use umbraco.library:GetXmlNodeById() instead ...)
/Chriztian
Chriztian,
This seems to be working perfectly now. You've helped me out greatly, thanks!
is working on a reply...