updating a dynamic meta data set to be checkboxes

matthew.wren's Avatar

matthew.wren

06 Mar, 2015 09:01 PM

On our news site we have a Dynamic Metadata field that allows a user to type out categories which allows our Releases and Announcements to be filtered. The problem I see is that these have to be manually added which can allow inconsistencies and errors. I think it'd be easier to just have checkboxes in place so it's consistent and easier.

I attached what our current Metadata and the one I just created. You can see the fucntionality in action on this page.

I'm pretty sure the format that controls this is on this page and this is the line:

<div class="listcont">
                <h3><a href="{path}"><xsl:value-of select="title"/></a></h3>
                <p><xsl:value-of select="hh:convertDate(number(created-on))"/></p>
                <xsl:copy-of select="description/node()"/>
                <div class="cats"><xsl:text>Categories: </xsl:text><xsl:value-of select="dynamic-metadata[name='tags']/value"/></div>
                <div class="checkcats" style="display:none;"><xsl:call-template name="cleanWords"><xsl:with-param name="keywords" select="dynamic-metadata[name='tags']/value"/></xsl:call-template></div>
            </div>

Is there a way to update this format so that it can take the values of the checkboxes so users don't have to type out categories every time?

  1. 1 Posted by Ryan Griffith on 09 Mar, 2015 02:18 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    Instead of outputting a single string like the following:

    <div class="cats"><xsl:text>Categories: </xsl:text><xsl:value-of select="dynamic-metadata[name='tags']/value"/></div>
    

    You would want to loop over the checkbox items using an xsl:for-each or xsl:apply-templates tag:

    <div class="cats"><xsl:text>Categories: </xsl:text>
      <xsl:for-each select="dynamic-metadata[name='tags']/value">
        <xsl:value-of select="."/>
      </xsl:for-each>
    </div>
    

    OR:

    ...
    <div class="cats"><xsl:text>Categories: </xsl:text>
      <xsl:apply-templates select="dynamic-metadata[name='tags']/value" mode="tag" />
    </div>
    ...
    <xsl:template match="value" mode="tag">
        <xsl:value-of select="."/>
    </xsl:template>
    

    Note: I used <xsl:template match="value" mode="tag"> here because the name of match of the template is generic and could potentially be used on other elements. Adding the mode attribute means the template will only be called when you specify the mode in the apply tag, like in the example above.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by matthew.wren on 10 Mar, 2015 07:25 PM

    matthew.wren's Avatar

    I think this did the trick. Thanks again!

  3. 3 Posted by Ryan Griffith on 10 Mar, 2015 07:34 PM

    Ryan Griffith's Avatar

    Not a problem at all, Matthew, thank you for following up.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 10 Mar, 2015 07:34 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM