Different DS, same Section and identical templates
This is an open discussion with 6 replies, filed under XSLT.
Search
If it's just a case of applying the same template to entries from two different data sources that are from the same section, you can use:
<xsl:apply-templates select="/data/*[section/@handle='page-content']/entry"/>
and:
<xsl:template match="/data/*[section/@handle='page-content']/entry">
Ob.vi.ous.ly
Thanks David. This looks like the elegant solution I had in (my fried) mind…
:) Cool. I must admit that I didn't fully understand the first part where you describe why you need two data sources. I'm wondering if you could add two different filters to one data source to accomplish the same thing?
I (think) I need 2 DS'es because in the first (default) case I want to fetch Page Content entries based on the parent Symphony Page ID (/foo
=> Page 'foo') , and in the second case I need to fetch entries based on the Entry's title
(/extra/entry-title
).
There's probably a better way ™
Wouldn't this do the trick?
<xsl:template match="entry" mode="page-content"> <xsl:apply-templates select="/data/page-content/entry | /data/extra-page-content/entry" mode="page-content">
designermonkey: it does as per my first requirement (same template for two ds-root-nodes) but IMHO it is slightly less elegant than David's solution.
I wonder what you think about my other point though: do I need two DS'es?
Create an account or sign in to comment.
It's been a while since I've been working with Symphony and I am getting a litte rusty.
I am currently in the position of having 2 DS'es:
page-content
andextra-page-content
. Both target entries from the same SectionPage Content
(contentpages linked to Sym. Pages). Both output the same fields from the matched entries.The reason I (think) I need those 2 DS'es is because I use
page-content
to matchPage Content
entries based on{$current-page-id}
: (/foo
matches Page Content entries linked to Sym. Pagefoo
)But I have one extra 'special' Symphony page:
Extra
: this page has a page paramtitle
and fetches the corresponding Page Content entry based on it's title/@handle (/extra/bar => entry 'bar'
)Now: I want to use the same XSLT template to output identical HTML for entries matched by both
page-content
andextra-page-content
but obviously the DS root XML node is named differently:/data/page-content/entry
v.s./data/extra-page-content/entry
.I tried setting a param
$page
in my XSLT to the different node-sets but that did not work.Right now I apply a simple hack: I manually renamed my
extra-page-content
DS root XML node topage-content
(identical to original DS) :)There must be a better way. This guys needs coffee and some help from the Symphony Guru's. TIA.