Copied to clipboard

Flag this post as spam?

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


  • Bent Holz 100 posts 273 karma points
    Jul 06, 2011 @ 12:09
    Bent Holz
    0

    Replace comma in id listing

    New at xslt so this might be simple to everyone else...

    I have the following page setup with subpages:

    Products
    -- Product 1
    -- Product 2
    -- Product 3

    Category
    -- Cat 1
    -- Cat 2
    -- Cat 3

    Each product can belong to multiple categories, and i've added a checkbox under the product creation page where you select witch ones...

    When i list witch categories each product belongs to, i get the id's of the category pages
    (ex. 1080,1081,1093...)

    But in my xslt i would like to remove the comma an replace it with a space (ex. 1080 1081 1093...) but i can't figure out how to do it...

    <xsl:value-of select="produktKategori"/> lists the id's

    and from what i have found this could do the trick:

    <xsl:variable name="values" select="concat($currentPage/aliasOfCheckbox,',')"/>
    <xsl:value-of select="umbraco.library:Replace($values, ',', ' ')" />

    but where and what do i write to change it?


     

  • Rich Green 2246 posts 4008 karma points
    Jul 06, 2011 @ 12:36
    Rich Green
    2

    Hey,

    It should just be  

    <xsl:value-of select="umbraco.library:Replace(produktKategori, ',', ' ')" /> 

    Rich

  • Bent Holz 100 posts 273 karma points
    Jul 06, 2011 @ 13:12
    Bent Holz
    0

    Damn that was quick...

    ...and it works :)

     

    What i ultimately wanna end up wit is something like this:

    <div class="<xsl:value-of select="umbraco.library:Replace(produktKategori, ',', ' ')" />">

    <p>some content</p>

    </div>

     But alas no go... back to the drawing board

  • Bent Holz 100 posts 273 karma points
    Jul 06, 2011 @ 13:45
    Bent Holz
    0

    Got that working now :)

    <xsl:variable name="classID"><xsl:value-of select="umbraco.library:Replace(produktKategori, ',', ' ')" /></xsl:variable>

    <div class="{$classID}">

    <p>some content</p>

    </div>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 06, 2011 @ 14:10
    Lee Kelleher
    0

    Hi Crawn,

    To do the inline XPath for the class attribute, you can do this:

    <div class="{umbraco.library:Replace(produktKategori, ',', ' ')}">

    Saves you storing it in a variable (unless you are going to use it again later on?)

    Cheers, Lee.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jul 06, 2011 @ 23:00
    Chriztian Steinmeier
    1

    Being the ultimate mr. annoying (sorry :-) - I'd like to point out that class names starting with a digit shouldn't work (in a standards compliant browser, anyway), so if you're hpoing to style your <div> using the ID's as class names, I'd suggest you prefix them with a "c" or some other letter, e.g.:

    <div class="c{umbraco.library:Replace(produktKategori, ',', ' c')}">

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft