Hi,
We are using 4.16.0. We have a need to check whether the asset_contents of our alternative context is blank.
Is there a way to do this using a keyword?
Thanks,
Graham
Hi,
We are using 4.16.0. We have a need to check whether the asset_contents of our alternative context is blank.
Is there a way to do this using a keyword?
Thanks,
Graham
Using the context modifier on the asset contents keyword you should be able to do something like:
%asset_contents_raw^context:<context_name>^empty:TRUE%
http://manuals.matrix.squizsuite.net/keyword-replacements/chapters/contexts
Hi Bart,
Many thanks. We'll give that a go.
Graham
Hi Bart,
To start off, I've tried both %asset_contents_raw% in the Paint Layout and %globals_asset_contents_raw% in the Design parse file but both print nothing at all. What could be wrong?
(The page in question has two WYSIWYG containers with alot of text in)
Graham
Not sure, would have to get more information about your complete set up in order to see what's wrong, as %asset_contents_raw% should simply just print the contents without the paint layout content. What about if you just print %asset_contents%?
Hi Bart,
%asset_contents% works as expected. I'll try and work out whether anything is interfering.
Graham
Hi,
I've created a simple Design which has just a body design area in it. Then I have a single Standard Page which uses that Design. I also have a Paint Layout applied to the page which has a Default format and nothing else.
I've tried %asset_contents_raw^context:Welsh% (Welsh is our alternative context) but it just prints out "%asset_contents_raw%" literally (ie that exact string, not my rendered content). I've also tried %asset_contents^context:Welsh% and this prints out "%asset_contents%" literally.
I've tried this when the alternative (Welsh) context has not been touched (ie is properly empty) and also when there is some content in the alternative context. Both times, I just get the "%asset_contents%" string printed out.
I've tried with %globals_asset_contents_raw^context:Welsh% as well but this prints nothing at all.
However, interestingly, if I hardcode the current assetid it does work, as follows:
%globals_asset_contents_raw:17137^context:Welsh%
This prints out the Welsh content as we want it to.
Ultimately what I am trying to do is check whether the Welsh context is blank so there may be another way to do this. I'd appreciate any advice.
Many thanks,
Graham
What about if you try %globals_asset_contents^context:<context_name>^empty:TRUE%
Hi Bart,
It seems to display "TRUE" whether it is populated or not. I've got two pages and one has Welsh content but the other does not. That keyword prints TRUE for both. I've also tried using that keyword to check the English context (which is populated for both) and it prints TRUE for those as well.
Graham
What about if you first check printing
%globals_asset_contents^wordcount%
and
%globals_asset_contents^context:<context_name>^wordcount%
Does the context that is empty print 0?
If it does, you could try to do %globals_asset_contents^context:<context_name>^wordcount^eq:0:FALSE:TRUE%
Hi,
Thanks for coming back so quickly.
%asset_contents^wordcount% prints 13
%globals_asset_contents^wordcount% prints 0
%globals_asset_contents^context:Welsh^wordcount% prints 0
%asset_contents^context:Welsh^wordcount% gives a PHP error
PHP Warning
array_keys() expects parameter 1 to be array, boolean given
<p> 
PHP Error
Argument 2 passed to Paint_Layout_Bodycopy::_getAssetKeywordReplacements() must be an array, null given, called in [SYSTEM_ROOT]/core/assets/paint_layout/paint_layout_bodycopy/paint_layout_bodycopy.inc on line 274 and defined
The PHP error sounds like a bug, I'll report that for you.
But it's interesting that you are getting different results for globals. Where exactly are you printing this keyword? In the type format bodycopy of a paintlayout?
However, if the welsh content is empty, then %globals_asset_contents^context:Welsh^wordcount% looks to be working for you in which case I would try to use %globals_asset_contents^context:Welsh^wordcount^eq:0:FALSE:TRUE%
Hi,
I forgot to say I have tried %globals_asset_contents^context:Welsh^wordcount% when the Welsh context is populated as well and it always returns 0.
I've tried the keywords in a Design parse file, inside a page's contents and also in the Type format of a Paint Layout which is applied to the page. They all do the same thing.
Cheers,
G
And when it is populated, does %globals_asset_contents^context:Welsh% actually return any content?
Hi,
No it returns nothing at all.
Also:
%globals_asset_contents_raw^context:Welsh% returns the same PHP error
%globals_asset_contents_raw:17340^context:Welsh% works perfectly
However, I can't figure out a way to dynamically populate the assetid in that keyword replacement.
:)
Graham
Hmm, what asset ID gets printed if you just go %globals_asset_assetid% ? Is it 17340 ?
If it's not, then you are not printing the keyword within the context of the correct asset you want.
Hi,
Yes, %globals_asset_assetid% returns the ID as expected but %globals_asset_contents% in the same page layout bodycopy returns nothing. (%asset_contents% works fine)
Graham
What about if you use: %globals_asset_assetid^as_asset:asset_contents%
Hi Bart,
I am making a little progress.
I decided not to try and check the %asset_contents% for now. Instead I am trying to do it via the page name. I figure if the name has been translated into Welsh we can probably assume the rest of the page is too.
I have gotten this to work using a conditional keyword as follows:
[attachment=698:name_is_translated.jpg]
I THINK this works reliably.
:)
G name_is_translated.jpg (25.1 KB)