Yet another question! Attempting to assign language values to variables
This is an open discussion with 24 replies, filed under XSLT.
Search
So this is what I think you want to achieve:
Inside the Single Job (single-job
) Data Source there is a field named “Hours” which is a select box: Full Time or Part Time. These two text values match up to two fields inside the Language Data Source so that they can also be translated into Welsh.
So assuming your $language
variable holds the correct language/entry
for the language you want to display, you can get the text string like this:
<!-- a global $language variable I presume you already have --> <xsl:variable name="language" select="/data/language/entry"/> <xsl:template match="single-job/entry"> <!-- assume this is the template writing our Job details --> Type: <xsl:value-of select="$language/*[name()=current()/hours/item/@handle]"/> </xsl:template>
Inside the template matching on single-job/entry
(the entry is the context node) you then need to look up inside the $language
variable for a node name matching the handle of the (English) type chosen in the select box.
Is that right?
Hi Nick,
This is getting there.. not sure about language variable… $labels was the one Throlkim was using to refer to the different language entries..
And even though the page/xsl file I want this code to sit in is called single-job.xsl
The field named hours is stored in a data source called “Job Table” so I guess changing the template match to “job-table/entry” is a start?
There is a data source called languages as well but not sure if this is the right source to point at for the variable..
Will report back with my findings.
Also “Views” Extension” any way of adding a re-set to “0” from the admin panel? so selecting all my jobs entries and then bottom right - with selected box.. having an option to reset all views to 0?
This would help things as it is not live yet we could reset views for actual accuracy of views by users!
<xsl:variable name="languages" select="/data/languages/entry"/> <xsl:value-of select="$labels/*[name()=current()/hours/item/@handle]"/>
This worked!!!
Thank you oh great one!!!
Woo, nice to see we finally have a solution for that. Thanks for sticking with our rather strange requests :)
Create an account or sign in to comment.
Basically, we need to select a language option from $labels. All options are $labels/full-time or $labels/part-time etc. Ideally what we wanted to do was use the value of $hours to form the second part of that request. So if $hours was set to ‘full-time’, $labels/$hours would form $labels/full-time.
Nick’s solution looks better than the one we’ve tried, but moonoo’s given it a go to no avail. Dynamic variables seemed so logical in my head, it’s a shame XSL doesn’t naturally support them!
And my apologies for the massive amount of language elements in the XML: I’ve come up with a better way of doing languages since, but it’s not really feasible to go back and change it. :D