I am using the uComponent countryPicker as multiple select box. Now i want to check in XSLT if an value is an element of the selected items of the list
How can i do this in xslt? Can someone please help?
I'd say check the docs: http://ucomponents.codeplex.com/documentation but there isn't much there for the country picker one! If you have a look at your Umbraco XML file, you should be able to find the page with the country picker on and see what format the data is in. I don't have an install that uses it to hand, if you can check on your and show me what the XML for it looks like, I can help!
If you want to have a list of the selected countries then you need to use the umbraco.library:Split() extension, since the selected countries are stored as a comma seperated list like "Albania, Germany" etc.
Aaah...then it makes sense! Seems like I have misunderstood your post totally.
I thought you used the countrypicker on a node in the content section. That is what my code is intended for.
I'm willing to try and see if I can somehow figure something out with just fetching the values directly from the datatype...but it can't be untill at earliest tonight.
I'm not sure whether there is a bug with this extension in 4.7 or not. According to this WIKI entry http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalues you should get some XML returned where you get all the prevalues and their content. This is not the case for you or for me...
So perhaps it's a bug?...I'm just not sure if it's a bug with the extension or the country picker...
In order to solve your problem I'm wondering if you use the countrypicker as a property on one of your nodes in the content tree? Because then I guess it's a matter of fetching that node in XSLT and the run through the values as shown earlier...
I created a new datatype called "countryPickerList" with uComponents CountryPicker. In the settings of this datatype i selected "ListBox" so i am able to select more then one Country.
I then created a new mediatype property called "bannerCountryYES"
What i now want to do in XSLT is to look if the country the user is inside (i get it by a localisation script or by selection on a landing page) is one of the selected values of the "bannerCountryYES" property.
XLST check if item is in multiple list
Hello,
I am using the uComponent countryPicker as multiple select box. Now i want to check in XSLT if an value is an element of the selected items of the list
How can i do this in xslt? Can someone please help?
Thanks
Hiya,
I'd say check the docs: http://ucomponents.codeplex.com/documentation but there isn't much there for the country picker one! If you have a look at your Umbraco XML file, you should be able to find the page with the country picker on and see what format the data is in. I don't have an install that uses it to hand, if you can check on your and show me what the XML for it looks like, I can help!
:)
Hi Tim,
I looked into this documentation but cannnot find anything.
So please tell me where i find the xml and i will paste it here :-)
Thanks
What i just did is:
<xsl:value-of select="umbraco.library:GetPreValues('1806')"/>
But now i get ListBoxListBoxListBox instead of the values :-)
The XML for the site is in "/app_data/umbraco.config" that should have the xml for your whole site in it!
For the other thing you're trying, you can try <xsl:copy-of select="umbraco.library:GetPreValues('1806')" disable-output-escaping="true"/>
:)
your code gives me an error. Also if i use disable-output-escaping="yes".
I now tried this code:
Now i get some ids but how get i the value?
If i look into the property and look in the sourcecode the values are "Albania", "Germany" etc.
Thanks
Hi Dominik
What XML is getting returned if you write it out in a <textarea></textarea> section?
<textarea>
<xsl:copy-of select="$countryList" />
</textarea>
Maybe you just need to write <xsl:value-of select="." /> instead of @id?
/Jan
Hi Jan i get this one:
But i always get "ListBox" this is the type i can choose on CountryPicker but i need the countries like they are displayed in the multiple list
Thanks for help
Hiya,
umbraco.library:GetPreValueAsString(23) should get you the actual value of the prevalue, based on it's id (replace the 23 with the id).
Hi Dominik
If you want to have a list of the selected countries then you need to use the umbraco.library:Split() extension, since the selected countries are stored as a comma seperated list like "Albania, Germany" etc.
Then you can use this code to generate the list
<xsl:variable name="country" select="$currentPage/country" />
<xsl:variable name="countries" select="umbraco.library:Split($country,',')" />
<!--<textarea>
<xsl:copy-of select="$countries" />
</textarea>-->
<ul>
<xsl:for-each select="$countries//value">
<li><xsl:value-of select="." /></li>
</xsl:for-each>
</ul>
Is this what you're after?
/Jan
If you don't want the for-each stuff you should also be able to create the list like this...
<xsl:template match="/">
<xsl:variable name="country" select="$currentPage/country" />
<xsl:variable name="countries" select="umbraco.library:Split($country,',')" />
<xsl:apply-templates select="$countries" />
</xsl:template>
<xsl:template match="value">
<li><xsl:value-of select="." /></li>
</xsl:template>
/Jan
Hi Dominik
Did you get this solved?
/Jan
hi Jan,
i will try it on tuesday. Today and MOnday are holidays in Germany :D
Thanks for your response
Hi Dominik
Ah yes...easter it is :-)
/Jan
Hi Jan,
Now i am coming back to you :)
In your script you wrote:
But i need to get the values out of anohter property (not called country).
I also tried to use my property Alias instead of country but still get no countries
Thanks
Hey Jan can you please respond?
Jan it would be really nice if you can tell me how i can get the selected values :-)
Hi Dominik
Did you copy the exact code I showed before?
Could you please try
<xsl:variable name="country" select="$currentPage/country" /> (Instead of Country use your document type alias)
<textarea>
<xsl:copy-of select="$country" />
</textarea>
What does the XML look like then?
/Jan
If i use this code i get a textarea with the complete HTML code of my site inside
Ok, that's because the variable is empty...
Where does the node you'e trying to fetch the countries for live in your document tree? How is the content structure?
Perhaps you need to use the GetXmlNodeById extension and feed it with the id of the node in order to get the XML returned?
/Jan
Hey Jan,
i just tried the following script
now i get the following inside each textarea:
<preValues><preValue id="187">ListBox</preValue><preValue id="188"></preValue></preValues>
But just a value not the name of the country.
Perhaps this helps
Hi Dominik
Yes, that makes sense. But as far as I know you are looking to get the countires, right? :-)
What is 1806? Is that the ID of the node where you have selected your countries?
/Jan
Yes i want to get the countries :-)
1806 is the ID of the datatype i have created for the multiple countrPicker list
Hi Dominik...
Aaah...then it makes sense! Seems like I have misunderstood your post totally.
I thought you used the countrypicker on a node in the content section. That is what my code is intended for.
I'm willing to try and see if I can somehow figure something out with just fetching the values directly from the datatype...but it can't be untill at earliest tonight.
/Jan
its ok jan,
great support :-)
thanks for all
Jan? Any news about this problem?
What if we have a prevalue that has a comma in it?? Can we change the default separator from "," to something else?
Also, what is the recommended way to translate this kind of lists?
Duarte
Jan can you please help?
Hi Dominik
Sorry about my late answer to this.
I'm not sure whether there is a bug with this extension in 4.7 or not. According to this WIKI entry http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalues you should get some XML returned where you get all the prevalues and their content. This is not the case for you or for me...
So perhaps it's a bug?...I'm just not sure if it's a bug with the extension or the country picker...
In order to solve your problem I'm wondering if you use the countrypicker as a property on one of your nodes in the content tree? Because then I guess it's a matter of fetching that node in XSLT and the run through the values as shown earlier...
/Jan
Hi Jan,
So I will try to explain it once again.
I created a new datatype called "countryPickerList" with uComponents CountryPicker.
In the settings of this datatype i selected "ListBox" so i am able to select more then one Country.
I then created a new mediatype property called "bannerCountryYES"
What i now want to do in XSLT is to look if the country the user is inside (i get it by a localisation script or by selection on a landing page) is one of the selected values of the "bannerCountryYES" property.
Hope you now understand what i am trying to do
is working on a reply...