I’ve almost finished converting my templates to Velocity and I’m trying to get an assembly template to display the label of a checkbox choice (rather than the Y that is stored in the db).
This function works: $rx.keyword.getChoiceLabel(contenttypename, fieldname, value)
but I need a way to check if the value is “Y” for each checkbox choice and then display the label if it is a “Y” and not empty.
I tried #ifnotnull(“topic”) [li]$rx.keyword.getChoiceLabel(“Bio”, “topic”, “Y”) [/li]
(This is meant to produce a bulleted list of topics that a speaker will discuss based on a predefined list that they submit to us)
I’m not real clear on exactly what you’re trying to do. It sounds like you want to display values from a checkbox group based on whether they are checked or not.
Basically, I’m trying to get a list of topics to be listed rather than a list of "Y"s. The “Bio” content editor allows our end users to check any number of topics that a speaker is an “expert” on. i.e. accounting; estate planning; tax planning; etc.
Currently, if I use #fieldIfSet(accounting) and they have it checked it will display “Y” (and if it’s not checked it displays nothing). If I use the $rx.keyword.getChoiceLabel(“Bio”, “Accounting”, “Y”) the template will display the topic label “Accounting” regardless of whether or not the speaker is an expert in that topic (because I’ve set the value to Y).
I’m looking for a way to put conditional logic on the value attribute of the getChoiceLabel function. i.e. if the value is Y (or not null) for accounting; display the label; otherwise, don’t display anything.
If I have a single checkbox (i.e. ungrouped) which has a value of either Y or null and I want it to display alternate text if the value is Y and nothing if it’s null - how do I do this?
I’ve looked at the code sample - what are the variables referring to $a; $lbl; $label; $delimiter, and mykwd?
This is what the previous markup looked like (but I would prefer if in velocity I could read the label (defined in the sys_SingleCheckbox “choices defined for this control only”):
xsl:if test="//acct_career_ed!=’’">
li>
xsl:choose>
xsl:when test="$syscommand=‘editrc’">
span psxedit=“acct_career_ed”>
xsl:value-of select="//acct_career_ed" />
/span>
/xsl:when>
xsl:otherwise>
xsl:text>Accounting Careers and Education</xsl:text>
/xsl:otherwise>
/xsl:choose>
/li>
/xsl:if>
I had a look at some of the other posts and I found one with some code (http://forum.percussion.com/showthread.php?t=112)that I used along with the function that was sent originally and it seems to work. There may be a better way …
There are 2 general ways to do this in an XSL assembler.
The first (and simplest) way is to do an outer join in the query resource to the RXLOOKUP table (or whatever table your keywords are stored in). You’ll need to add the label column to the mapper, and then it will be available directly in the XML.
The second way is to use a document() call to a separate query resource (supplying the id as a parameter). This is a little more complicated, but it gives you more control over what happens when the keyword is not found.