Dynamic XML Data Source filtering
This is an open discussion with 8 replies, filed under General.
Search
I've never tried it, but looking at the codebase, it should work.
This line should replace any params in your XPath with the correct value, before running the XPath expression. Have you tried wrapping the param with curly braces perhaps?
/language/section[@handle = {$current-page}]/*
While this isn't valid XPath on its own, it might force Symphony to interpret $current-page
as a parameter name.
Hi Nick,
thanks for the quick reply. Sadly, it does not work with the curly braces either. It's weird, i can use page params in the URL field of the data source but if i use them in the Included Elements field i get the following error in my xml:
<error>XML returned is invalid.</error> <errors> <item>XSLTProcessor::transformToXml(): runtime error: file /www/htdocs/w00d7fac/fbp/ line 5 element copy-of</item> <item>XSLTProcessor::transformToXml(): runtime error: file /www/htdocs/w00d7fac/fbp/ line 5 element copy-of</item> </errors>
if i replace $current-page with a page, say 'home', everything works as expected.
cheers
daniel
How frustrating — looks like that line isn't doing its job. You can use var_dump($this->dsParamXPATH);die;
just after that line to see the value of the XPath, perhaps check it before and after the replace has occurred. I'll submit a bug report.
Hmm I just got this working using Symphony 2.3beta.
- XML:
http://www.w3schools.com/xsl/cdcatalog.xml
- XPath:
//cd[year='{$url-year}']
Then attached to a page and loaded using:
/my-page/?year=1985&debug
The curly braces were required. I also didn't spot above that you need the single quotes around the parameter, so that it compares as a string rather than an XML element name.
@Nick, do you spotted Data source created about 6 hours ago. Create another? View all Data sources
when creating dymanic xml using the cdcatalog.xml?
Huh?
Found error with notice alert: https://github.com/symphonycms/symphony-2/issues/1262
Hi Nick,
thanks for looking into this!
Your "hack" with the curly braces and the single quotes worked in 2.2.5. Still a bug though from an xpath point of view ;) I would have never thought of putting a variable into single quotes *g
thank the heavens for this great community!
daniel
Create an account or sign in to comment.
Hi folks :)
is it not possible to filter by page params in the
Included Elements
field in a dynamic XML data source?I need to do something like:
thanks for any insight!
Daniel