Conditional keyword using data source record


(N Wallis) #1

Hi there, 

 

I have some JSON data:

            [id] => EVT-000097-Y78GKW
            [title] => SC Event Feb 15 2016 1
            [theme] => Conference/Seminar/Webinar
            [description] => A test of CRM for KL, KA, & AB.
            [start_time] => 2016-02-16T08:00:00
            [end_time] => 2016-02-17T08:00:00
            [max_registrations] => 0
            [off_campus] => 
            [location] => [{"campus":"Wimmera","building_room":"Wimmera (C100) MT Helen (F302)"},{"campus":"Mt Helen","building_room":"Wimmera (C100) MT Helen (F302)"}]
            [audience] => ["Prospective"]
            [type] => Workshop
            [custom_image] => 
            [images] => 
            [script] => events.push ({id:'EVT-000097-Y78GKW', location: 'Wimmera,Mt Helen', type: 'Conference/Seminar/Webinar', audience:'Prospective'});
            [tile_date] => Tue 16 Feb - Wed 17 Feb
            [tile_date_html] => 
16 Feb -
17 Feb
        [tile_location] => Wimmera & Mt Helen
        [loginRequired] => 

And I am successfully rendering this data in an asset listing.  I would like to add a condition to Data Source Record Format which belongs to my Asset Listing based on the login required parameter which is empty or 1.  And accessible using the keyword %ds__loginRequired%. 

 

Based on the documentation, I would have thought the following format would suffice:

 

%begin_ds__loginRequired%

...

%else_ds__loginRequired%

...

%end_ds__loginRequired%

 

How does this look to those more experienced in this area

 

- Are you able to use data source parameters in a conditional keyword like this? I have tried other modifiers like notempty etc.. 

 

Any ideas?


(Evan Wills) #2

Hi Nate

 

My understanding is that conditional keywords, only work with paint layouts.

The way I've used it is I've set up my asset listing then in the "Default Format" (or other relevant format), I've used

%asset_contents_paint_#####%

keyword (where ##### is the asset ID of the layout you want to use) to render the contents of my asset (or shadow asset in your case) using a paint layout. You then create your conditions on the "Conditional keywords" screen of the "Default Format" in your paint layout. You then dump all the code from the original "Default format" in from your asset listing into the "Default Format of your paint layout.


(N Wallis) #3

Thanks for the reply evan, although the docs tend to suggest that paint layouts have their implementation of conditional keywords.. am I reading that correctly?

 

https://manuals.matrix.squizsuite.net/keyword-replacements/chapters/conditional-keywords

 

By the sounds of things though, the conditional keywords I link to above can only not empty or empty as a comparison whether to render or not.   Maybe it doesn't like my JSON data..


(Bart Banda) #4

Standard conditional keywords (using empty/not empty comparisons) work anywhere, but the ones in the paint layout are different as they can be compared on specific values as well. 

 

What you are using above should work, but can't remember an example of where I've used it with data source assets.

 

 

What happens if you just print %ds__loginRequired^charcount%  Does it print 0?

 

If it does, you could try and do:

%begin_ds__loginRequired^charcount^gt:0:PRINT:%
  //print if NOT empty
%else_ds__loginRequired%
  //print if empty
%end_ds__loginRequired%

(Mahearnpad) #5

Great solution. That's just what I was looking for myself!  

 

thanks