Copied to clipboard

Flag this post as spam?

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


  • Stephen 204 posts 246 karma points
    Dec 21, 2011 @ 13:34
    Stephen
    0

    Getting a list of services based on a checkbox list item being checked

    Hey there...I have created a checkbox list datatype, which list all the rooms in a building.

    I then have a serviceItem doc type which uses the above datatype.  When the CMS user adds a new service item like "Flat screen TV" they can then check which room has this service.

    So far so good i think!?

    I now want to pull out using XSLT the list of services for each room, so my question is how do i check that a checkbox is checked?

    Cheers,

    Stephen

  • Rich Green 2246 posts 3991 karma points
    Dec 21, 2011 @ 13:53
    Rich Green
    1

    Hi Stephen,

    I would have a look at your App_Data/Umbraco.config file and see who the data is held, if I remember rightly it's CSV.

    So you can use a 'contains' in XSLT, remember to add a preceeding and trailing comma, so you get an exact match.

    Hope this helps

    Rich

  • Stephen 204 posts 246 karma points
    Dec 21, 2011 @ 16:11
    Stephen
    0

    Hey Rich thanks for the heads up on that worked a treat...I'm now thinking i want to extend this further... :-)

    I've made my working XSLT a macro and allowed the user to insert via editor...can i use the datatype checkbox list that i created to enter the macro parameters?

    I dont see the option in the parameter type dropdown...

    Stephen

  • Rich Green 2246 posts 3991 karma points
    Dec 21, 2011 @ 16:18
    Rich Green
    0

    Hey Stephen,

    Glad you got that one bit worked out.

    Not sure I understand your other question?

    Rich

  • Stephen 204 posts 246 karma points
    Dec 21, 2011 @ 16:53
    Stephen
    0

    often the case!

    Ok i have my XSLT that lists services by room like so...

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      exclude-result-prefixes="msxml umbraco.library">

        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <xsl:template match="/">

             <h3><xsl:value-of select="$currentPage/@nodeName" /> Services</h3>
             
                <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc]/ServiceHome/* [@isDoc]">
                    <xsl:sort select="@createDate" order="ascending"/>
                  
                    <!-- Position() <= $noOfItems -->
                   
                     <xsl:if test="contains(rooms, 'The London Room')">    
                 
                     <h4><xsl:value-of select="@nodeName" /></h4>
                     <p><xsl:value-of select="umbraco.library:StripHtml(serviceDescription)"/></p>
                  
                     </xsl:if>  

                </xsl:for-each>

        </xsl:template>

    </xsl:stylesheet>


    So i've made this a macro so that the user can insert the code above into a text editor.  However the above code use the hardcoded "The London Room" where as i would like to let the user select which room they want when inserting the macro.

    It would seem the best way would be to re-use the datatype checkbox list of the rooms but can i do this for the parameters?

    S

Please Sign in or register to post replies

Write your reply to:

Draft