Troubles with paint layouts and contexts when using conditional keywords


(Hopkinsd1) #1

Hello,

 

I seem to be having troubles with paint layouts and contexts when using conditional keywords.

 

I have two contexts, English and Welsh.

 

Each page has a paint layout applied and I can add html or keywords to each paint layout independently and it is represented correctly in each context when viewing the page.

 

I can edit one context within the paint layout, save it and view the changes on my page. I should note that both contexts still render correctly.

 

However when I create and introduce some conditional keywords (I have attached the ones I created) it all goes wrong.

 

Using this code in my paint layout results in me only being able to have one context work at a time, which ever one I save last. English context %begin_is_welsh%

This page is welsh only.
%end_is_welsh% %asset_contents%
Welsh context
%begin_is_english%
<div class="alert">This page is English only.</div>
%end_is_english%
%asset_contents%
 
Has anyone experienced this before?
 
Thanks
David

  conditionalkeywords.JPG (29.6 KB)


(Bart Banda) #2

Not sure what the issue is, but 1 thing I do notice that your above code will print the asset contents twice. Which is probably not what you want.

 

Could you not simplify it though by using conditional keywords? Something like:

%begin_asset_metadata_page.contentlanguage^eq:English|Welsh:True:%
<div class="alert">This page is %asset_metadata_page.contentlanguage% only.</div>
%end_asset_metadata_page.contentlanguage^eq:English|Welsh:True:%

That way, the div would only be displayed if the value equals English or Welsh, and you wouldn't have to use a conditional keyword in the paint layout. I haven't tested the above code yet though, so if that doesn't work, you could always translate this condition check into a paint layout check instead, and just use 1 conditional keyword.