Copied to clipboard

Flag this post as spam?

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


  • Profiterole 232 posts 264 karma points
    Jan 13, 2011 @ 02:20
    Profiterole
    0

    How to put space before comma separeted list

    Hi, in my docType a have a property (profMatiere)  with checkboxes. I call it in my template with the following umbraco:item

                <umbraco:Item field="profMatiere" runat="server" textifEmpty="Mathématiques"/>

    So if there's many checkboxes ticked, it gives me this : item1,item2,item3

    I'd like to have item1, item2, item3 with a space between the comma and the items. I supposed that it needs a xslt macro, but I don't know more...

    Thank you for your advice and help!

     

  • Sascha Wolter 615 posts 1101 karma points
    Jan 13, 2011 @ 04:27
    Sascha Wolter
    3

    Hi Profiterole,

    in your case the result can be achieved with a bit of inline Xslt:

    <umbraco:Item field="profMatiere" runat="server" textifEmpty="Mathématiques" xslt="Exslt.ExsltStrings:replace({0}, ',', ', ')"/>

    That basically replaces each ',' with ', ' in your output string.

    Hope that helps,

    Sascha

     

  • Profiterole 232 posts 264 karma points
    Jan 13, 2011 @ 11:47
    Profiterole
    0

    Thank you Sascha. Obvously I'm not enough good in xslt!

  • Sascha Wolter 615 posts 1101 karma points
    Jan 14, 2011 @ 00:23
    Sascha Wolter
    0

    Hi Profiterole,

    don't worry, I always have to look up the correct syntax for inline xslt myself as I rarely use it, but from time to time it comes in really handy. The most important part is to know that you can do such a thing, so I wouldn't say that you are not good enough with xslt. ;)

    Your initial idea was for 99% of the cases where you have to handle these comma separated values right: you split them with Xslt and act upon each node id/entry. Only in this case there was a nicer and quicker way to do it. :D

    Glad I could help out,

    Sascha

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies