Complicated: select multiple nodes to display in a list using XSLT
Hi
I am making a site for someone who breeds and sells horses. On this site I have created a document type called "horse" which contains a number of properties to collect and display information about that particular horse. Each horse has its own node, and these nodes can be located under 1out of number of different parent nodes, such as: "Horses for sale", Horses Sold", "Competing horses" etc.
I would like to maintain that each horse only has 1 node so that you will not need to update it's information in more than one place. However, some of the horses are used for breeding, which means that some of the horses are also the parents of some of the other horses.
Now here's the problem:
For the horses used for breeding I need to show a list of their offspring when the user is viewing the details of that horse, preferably with a link to the node for each foal in the list.
So I want my EDITOR to be able to select the nodes of all that horses 'children' and then use these selected nodes to display a list of the 'children'.
Honestly I have NO idea what is the best way to do this, I'm hoping some of you guys have some suggestions.
I'm thinking you should add a content picker property on the horse document type (since the relation is 1-1), which you can use to select the parent horse.
Then in your XSLT you can fetch the id with the umbraco.library:GetXmlNodeById() extension and then retrieve the information about the parent horse. It should'nt be too complicated to achieve what you're after then.
Alternatively you can configure an instance of the ultimate picker where you can get the possible horses listed in a dropdown box on the content node - this also returns the id and the process in the XSLT will be the same...so I think you should go with the first mentioned option, unless you're client is liking the dropdown better than the content picker. It could be that the latter approach makes more sense to him/her.
Let us know if you need some further explanation and XSLT examples to get you moving :)
Hi. I would suggest changing the whole structure a bit. So that all horses would be in one single tree of parents and their offspring. Then turn the top level category ("Horses for sale", Horses Sold", "Competing horses" etc.) into a property (e.g. "Category") of the horse doctype (a drop-down list or a checkbox list). There'll be also additional profit that you will be able to let a horse to belong to several categories in case you implement this property as a checkbox list.
If you've got uComponents installed (you should - it's an excellent set of good stuff for Umbraco), I'd highly suggest you use the Multi-Node Tree Picker for this - you can then create a property called "offspring", and allow only "horse" nodes to be picked. I wrote an article about using the Multi-Node Tree Picker in XSLT, that you can look at to get the info needed to get it working.
Thanks for all of your great feedback - there's good stuff in all of your posts, so I've decided to do bit of a cocktail of al them. I have Installed uomponents - and I've got the Multiple-Node Tree Picker working on my Horse document Type. But the XSLT is causing me problems. I've called my Data Type:"SelectFoal"
I've made an XLST and macro called "ListFoals" Which I have included on my Horse template. Ive tried modyfing the xslt from your article, but I'm a bit of a novice when it comes to XSLT - so it's not really working.
<xsl:template match="MultiNodePicker" mode="multipicker"> <!-- Handle all the nodeIds in one go (!) --> <xsl:apply-templates select="key('document-by-id', nodeId)" /> </xsl:template>
At the bottom I've reused the XSLT that I originally made for displaying the offspring in a list - This might have to be remodelled a bit, but It contains most of the properties that I'd like to display in the list.
However I'm convinced that the problems is that I'm not getting the data from the Picker right - Can you guys see what wrong?
It looks pretty good, actually - it's probably down to a typo or similar at this point; Check that the *property* on $currentPage actually has the alias "SelectFoals" (i.e.: The Umbraco GUI will try hard to name it "selectFoals" if you type "Select Foals" in the Name field, but it's still possible to override that).
You just nailed it - that was exactly the problem :) I changed "SelectFoals" to "selectFoals" and it now works like a treat. Thanks so much for your help :)
And btw. I also changed the strucure so that all the horses a now contained under the same parent note. I have then applied true/false checkboxes for wether the horse is in the breeding programme, for sale etc. Now I can call the horses into lists using XSLT, according to which checkboxes are checked. This is much easer for the Client to handle - so thank you to all of you :D
Complicated: select multiple nodes to display in a list using XSLT
Hi
I am making a site for someone who breeds and sells horses. On this site I have created a document type called "horse" which contains a number of properties to collect and display information about that particular horse. Each horse has its own node, and these nodes can be located under 1out of number of different parent nodes, such as: "Horses for sale", Horses Sold", "Competing horses" etc.
I would like to maintain that each horse only has 1 node so that you will not need to update it's information in more than one place. However, some of the horses are used for breeding, which means that some of the horses are also the parents of some of the other horses.
Now here's the problem:
For the horses used for breeding I need to show a list of their offspring when the user is viewing the details of that horse, preferably with a link to the node for each foal in the list.
So I want my EDITOR to be able to select the nodes of all that horses 'children' and then use these selected nodes to display a list of the 'children'.
Honestly I have NO idea what is the best way to do this, I'm hoping some of you guys have some suggestions.
BTW I'm using v. 4.7.0
Cheers Ulla
Hi Ulla
I'm thinking you should add a content picker property on the horse document type (since the relation is 1-1), which you can use to select the parent horse.
Then in your XSLT you can fetch the id with the umbraco.library:GetXmlNodeById() extension and then retrieve the information about the parent horse. It should'nt be too complicated to achieve what you're after then.
Alternatively you can configure an instance of the ultimate picker where you can get the possible horses listed in a dropdown box on the content node - this also returns the id and the process in the XSLT will be the same...so I think you should go with the first mentioned option, unless you're client is liking the dropdown better than the content picker. It could be that the latter approach makes more sense to him/her.
Let us know if you need some further explanation and XSLT examples to get you moving :)
Hope this helps.
/Jan
Hi. I would suggest changing the whole structure a bit. So that all horses would be in one single tree of parents and their offspring. Then turn the top level category ("Horses for sale", Horses Sold", "Competing horses" etc.) into a property (e.g. "Category") of the horse doctype (a drop-down list or a checkbox list). There'll be also additional profit that you will be able to let a horse to belong to several categories in case you implement this property as a checkbox list.
Hi Ulla,
If you've got uComponents installed (you should - it's an excellent set of good stuff for Umbraco), I'd highly suggest you use the Multi-Node Tree Picker for this - you can then create a property called "offspring", and allow only "horse" nodes to be picked. I wrote an article about using the Multi-Node Tree Picker in XSLT, that you can look at to get the info needed to get it working.
/Chriztian
Hi guys
Thanks for all of your great feedback - there's good stuff in all of your posts, so I've decided to do bit of a cocktail of al them. I have Installed uomponents - and I've got the Multiple-Node Tree Picker working on my Horse document Type. But the XSLT is causing me problems. I've called my Data Type:"SelectFoal"
I've made an XLST and macro called "ListFoals" Which I have included on my Horse template. Ive tried modyfing the xslt from your article, but I'm a bit of a novice when it comes to XSLT - so it's not really working.
My XSLT looks like this:
At the bottom I've reused the XSLT that I originally made for displaying the offspring in a list - This might have to be remodelled a bit, but It contains most of the properties that I'd like to display in the list.
However I'm convinced that the problems is that I'm not getting the data from the Picker right - Can you guys see what wrong?
Hi Ulla,
It looks pretty good, actually - it's probably down to a typo or similar at this point; Check that the *property* on $currentPage actually has the alias "SelectFoals" (i.e.: The Umbraco GUI will try hard to name it "selectFoals" if you type "Select Foals" in the Name field, but it's still possible to override that).
/Chriztian
Hi Christian
You just nailed it - that was exactly the problem :) I changed "SelectFoals" to "selectFoals" and it now works like a treat. Thanks so much for your help :)
And btw. I also changed the strucure so that all the horses a now contained under the same parent note. I have then applied true/false checkboxes for wether the horse is in the breeding programme, for sale etc. Now I can call the horses into lists using XSLT, according to which checkboxes are checked. This is much easer for the Client to handle - so thank you to all of you :D
Cheers Ulla :)
is working on a reply...