Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dominik 711 posts 733 karma points
    Apr 21, 2011 @ 10:29
    dominik
    0

    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

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Apr 21, 2011 @ 15:47
    Tim
    0

    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!

    :)

  • dominik 711 posts 733 karma points
    Apr 21, 2011 @ 15:53
    dominik
    0

    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

  • dominik 711 posts 733 karma points
    Apr 21, 2011 @ 16:19
    dominik
    0

    What i just did is:

     

    <xsl:value-of select="umbraco.library:GetPreValues('1806')"/> 

    But now i get ListBoxListBoxListBox instead of the values :-)


  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Apr 21, 2011 @ 16:24
    Tim
    0

    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"/> 

    :)

  • dominik 711 posts 733 karma points
    Apr 21, 2011 @ 16:35
    dominik
    0

    your code gives me an error. Also if i use disable-output-escaping="yes".

    I now tried this code:

    <xsl:variable name="countryList" select="umbraco.library:GetPreValues(1806)"/>
         <xsl:for-each select="$countryList/preValue">    
             <xsl:value-of select="@id"/>
    </xsl:for-each>-->

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 21, 2011 @ 16:49
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    Apr 21, 2011 @ 16:56
    dominik
    0

    Hi Jan i get this one:

    <preValues>
    <preValue id="187">ListBox</preValue>
    <preValue id="188"></preValue>
    </preValues>

    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

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Apr 21, 2011 @ 17:07
    Tim
    0

    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).

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 21, 2011 @ 17:20
    Jan Skovgaard
    0

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 21, 2011 @ 17:31
    Jan Skovgaard
    0

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2011 @ 13:39
    Jan Skovgaard
    0

    Hi Dominik

    Did you get this solved?

    /Jan

  • dominik 711 posts 733 karma points
    Apr 22, 2011 @ 20:46
    dominik
    0

    hi Jan,

    i will try it on tuesday. Today and MOnday are holidays in Germany :D

    Thanks for your response

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2011 @ 23:46
    Jan Skovgaard
    0

    Hi Dominik

    Ah yes...easter it is :-)

    /Jan

  • dominik 711 posts 733 karma points
    Apr 26, 2011 @ 10:03
    dominik
    0

    Hi Jan,

    Now i am coming back to you :)

    In your script you wrote:

    <xsl:variable name="country" select="$currentPage/country" />

    But i need to get the values out of anohter property  (not called country).

    <xsl:variable name="countryList" select="umbraco.library:GetPreValues(1806)"/>
         <xsl:for-each select="$countryList/preValue">    
             <xsl:value-of select="@id"/>
    </xsl:for-each>-->

    I also tried to use my property Alias instead of country but still get no countries

    Thanks

  • dominik 711 posts 733 karma points
    Apr 27, 2011 @ 10:44
    dominik
    0

    Hey Jan can you please respond?

  • dominik 711 posts 733 karma points
    Apr 28, 2011 @ 08:05
    dominik
    0

    Jan it would be really nice if you can tell me how i can get the selected values :-)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 28, 2011 @ 08:08
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    Apr 28, 2011 @ 08:15
    dominik
    0

    If i use this code i get a textarea with the complete HTML code of my site inside

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 28, 2011 @ 08:17
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    Apr 28, 2011 @ 08:20
    dominik
    0

    Hey Jan,

    i just tried the following script

       <xsl:variable name="countryList" select="umbraco.library:GetPreValues(1806)"/>
       
        <textarea>
        <xsl:copy-of select="$countryList" />
        </textarea>

    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

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 28, 2011 @ 09:15
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    Apr 28, 2011 @ 09:18
    dominik
    0

    Yes i want to get the countries :-)

    1806 is the ID of the datatype i have created for the multiple countrPicker list

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 28, 2011 @ 09:53
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    Apr 28, 2011 @ 09:55
    dominik
    0

    its ok jan,

    great support :-)

    thanks for all

  • dominik 711 posts 733 karma points
    May 02, 2011 @ 15:00
    dominik
    0

    Jan? Any news about this problem?

  • Duarte Carreira 47 posts 66 karma points
    May 02, 2011 @ 16:53
    Duarte Carreira
    0

    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

  • dominik 711 posts 733 karma points
    May 03, 2011 @ 09:24
    dominik
    0

    Jan can you please help?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 03, 2011 @ 23:12
    Jan Skovgaard
    0

    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

  • dominik 711 posts 733 karma points
    May 04, 2011 @ 08:22
    dominik
    0

    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

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft