jan_bogutzki
I'm new here

contentSelect with cms_value_param not working?

Jump to solution

Hi Community,

i try to consolidate some contentSelect-Functions into one. Therefore i define a Variable with the required value:

<CMS_FUNCTION name="define" resultname="qf_brand">

  <CMS_CDATA_PARAM name="source">

    <![CDATA[$CMS_TRIM(level:3,char:"")$

      $CMS_IF(ss_brand.equals("streetone"))$

        1

      $CMS_ELSE$

        0

      $CMS_END_IF$

    $CMS_END_TRIM$]]>

  </CMS_CDATA_PARAM>

</CMS_FUNCTION>

This part seems to work. The result is as expected after the header section. When i try to use this value in my contentSelect i get no results:

<CMS_FUNCTION name="contentSelect" resultname="cs_blogs_so">

  <CMS_VALUE_PARAM name="qf_brand" value="qf_brand" />

  <CMS_PARAM name="schema" value="Blogs" />

   <QUERY entityType="blog" limit="50">

    <FILTERPARAM parameter="qf_brand" datatype="java.lang.Boolean" value="1" />

    <EQ attribute="brand" parameter="qf_brand" />

    <ORDERCRITERIA attribute="date" descending="1"/>

  </QUERY>

</CMS_FUNCTION>

I already tried with java.lang.Integer as well as different variable names. The default value of FILTERPARAM makes no difference.

The datatype of attribute="brand" is xs:boolean.

Did i understand something wrong from the docs?

best regards

Jan

0 Kudos
1 Solution

Accepted Solutions
marro
Crownpeak employee

Hi Jan,

you functions do look good at first view. But I think you can't convert the value of the CMS_CDATA_PARAM to a Boolean. So I replaced (and simplified 😉 ) your first function by

<CMS_FUNCTION name="define" resultname="qf_brand"> 

  <CMS_VALUE_PARAM name="source" value='ss_brand.equals("streetone")'/> 

</CMS_FUNCTION>

This still hasn't worked, but by changing the datatype of the FILTERPARAM from Boolean to String finally got it working.

Best regards

Donato

View solution in original post

0 Kudos
5 Replies
marro
Crownpeak employee

Hi Jan,

you functions do look good at first view. But I think you can't convert the value of the CMS_CDATA_PARAM to a Boolean. So I replaced (and simplified 😉 ) your first function by

<CMS_FUNCTION name="define" resultname="qf_brand"> 

  <CMS_VALUE_PARAM name="source" value='ss_brand.equals("streetone")'/> 

</CMS_FUNCTION>

This still hasn't worked, but by changing the datatype of the FILTERPARAM from Boolean to String finally got it working.

Best regards

Donato

0 Kudos

Hi Donato,

thanks for your reply. This works, but additionally we have a problem with the value null. The solution is not extendable to use null as value for this boolean comparsion.

Would be great to use conditions in the query, just to replace such hack with define-Variables.

best regards

Jan

0 Kudos

Well, here is a solution without define and also working with null values 😉

<CMS_FUNCTION name="contentSelect" resultname="cs_blogs_so"> 

  <CMS_PARAM name="schema" value="Blogs" /> 

  <CMS_VALUE_PARAM name="qf_brand" value='ss_brand.equals("streetone")' /> 

   <QUERY entityType="blog" limit="50">

     <FILTERPARAM parameter="qf_brand" datatype="java.lang.String" value="1"/>

     <OR>

       <EQ attribute="brand" parameter="qf_brand" /> 

       <IS_NULL attribute="brand" />

     </OR>

     <ORDERCRITERIA attribute="date" descending="1"/>

  </QUERY> 

</CMS_FUNCTION>

Best regards

Donato

0 Kudos
marro
Crownpeak employee

You can of course combine EQ also with NOTNULL and using AND and/or OR in combination to get the result that you want.

0 Kudos

Hi Donato,

Thanks for your reply. The check if there is a null value only is required when testing for a false-Value. Thats the case i need a condition, because when true is tested, there must not be a null value result.

best regards

Jan

0 Kudos