0 users online. Create an account or sign in to join them.Users
Data source chaining
This is an open discussion with 9 replies, filed under General.
Search
Two sections, a Blog and a Comments section. The Comments section is linked to the Blog section using a Select Box Field.
On a frontend page you want to display the Blog and then all the related Comments after it. You can output the Blog's System ID in the Blog datasource and then use this parameter in the Comments datasource to only return the comments that are related to that Blog. So you chain the result of the Blog datasource into the Comments datasource.
That's a simple example. You can also have chains that's chain onto other datasources, or a datasource that chains from two others etc. :)
Thanks, Brendo; I can just about wrap my head around that. I'll dive in and see what happens.
D
OK – I've been fighting with this all day, but I've not really got anywhere (and I'm now mainly going round in circles).
I'm not sure if I'm only slightly off with a syntax error, or if I've missed something fundamental.
Do you know of any tutorials that might hold my hand through a worked example for this?
Thanks, D
David, what are the sections/data sources you are trying to chain, and what fields do they contain?
Hi David,
I've just extended the 'Say Hello to Symphony' tutorial a bit, to include a section, 'Responses', which I've connected to the 'Greetings' section using a Select Box Link.
I output $ds-greetings using the Greetings System ID and Filter my 'Responses' by the select box link (with the value {$ds-greetings} ).
I believe that this is conceptually along the right lines; do I now need to add something a bit more involved to my template in order to match up the system IDs for the Greetings and Responses? I think this might be my current stumbling block.
Thanks, D
I seem to have got it going with this:
<xsl:template match="greetings/entry">
<xsl:for-each select=".">
<h2><xsl:value-of select="name"/></h2>
<ul>
<xsl:for-each select="../../responses/entry/greeting/item[./@id = current()/@id]">
<li><xsl:value-of select="../../response-text" /></li>
</xsl:for-each>
</ul>
</xsl:for-each>
</xsl:template>
That was after quite a lot of trial, error and head-scratching.
It works -- but is it "right" (best practice, etc.)?
Thanks, D
wow ... :) I'm glad you're a fighter. Well, this is the way to do it:
<xsl:template match="greetings/entry">
<h2><xsl:value-of select="name"/></h2>
<ul>
<xsl:apply-templates select="/data/responses/entry[ greeting/item/@id = current()/@id ]" />
</ul>
</xsl:template>
<xsl:template match="responses/entry">
<li><xsl:value-of select="response-text" /></li>
</xsl:template>
Thanks Vlad – that looks way more manageable (although I saw the iterative approach I was going for demonstrated in this forum post – is there a right and wrong time to do it like that?)
Also, I find that I have to get the id from an 'item' tag that is one node deeper in the tree than the entry that I want to match it to (hence the '../'s in my solution above – I'm not sure if I've set everything up correctly (e.g. the select box link).
I don't think I've explained this very well, for which I apologise; if any of it makes sense, I'd be happy to hear suggestions. If not, I'll do my best to fully document what I'm trying to get across this evening.
Thanks, D
OK – forget I said anything; I've just figured out what my problem was – it's the similarity in naming between what the select box link and the section to which it links (duh!)
All sorted now; thanks very much.
D
Create an account or sign in to comment.
Would anyone be willing to put together a simple (contrived) example of when/how to implement data source chaining?
It might stop my head hurting at night if someone did.
Thanks, D