Can I use info from Shadow Assets in a paint layout?


(M L Sanders) #1

Hi

I've got a dynamically filtered XML Data Source that is returning shadow assets.

 

I'm then using an asset list to print out information from each, of the format %ds__Name%.

 

Question: I now need to change some content based on the value of these fields within the asset listing - for the more simple requirements (is the value this or that, for example) I can use a keyword modifier.

 

But for the more complex requirements - mostly, I need to print out information which uses other fields, I need to use a Paint Layout, and also really need Conditional Keyword functionality within that Paint Layout.

 

However, the Paint Layout doesn't let me access the %ds__Name% type fields at all, which is a real problem. Is there any way I can access these values (and then, maybe, use them as the basis for a conditional keyword)??

 

If not, I may be forced to do JS stuff within the asset listing, which I'd rather not do....

 

thanks all

 

mark


(Joel Porgand) #2

I don't think there's any way of pulling info out of a shadow asset directly. 


(Tim Davison) #3

Depending on the complexity of what you are trying to do you can often leave the paint layout off completely and just daisy-chain keywords and modifiers.  If you have some more specific examples I'm sure we could suggest some ways to use keywords/modifiers to get you 90% of the way?

 

*Assumption: I am assuming keyword modifiers work for data source keywords (like %ds__Name%).  I know some places keyword modifiers just do not work, and gets less frequent the later the matrix version.  So modifiers not working then all bets are off.


(Evan Wills) #4

HI Mark

 

One of the things we've done in the past (and continue to do in asset listings) is use the keyword modifiers like

  • "^empty",
  • "^notempty",
  • "^eq" or
  • "^preg_match"

to wrap stuff in comments or show something.

 

The way it works:

  1. You wrap the content you want hidden by default in HTML comments;
  2. Then immediatly after the opening comment to put the keyword you want to test with a one of the keyword modifiers above with a closing comment if the modifier is TRUE This closes the HTML comment so the content is now not hidden
  3. And immediatly before the closing comment you put the same keyword/modifier combination with an opening comment if the modifier condition is TRUE
    This opens a new HTML comment so you don't see the default closing comment

e.g.

<!--%ds__Name^notempty: -->%
This stuff is shown if % ds_Name % is not empty
%ds__Name^notempty:<!-- %-->

or

<!--%ds__Name^notempty: ^empty:-->%
This stuff is shown only if $ ds_Name % is empty
%ds__Name^notempty: ^empty:<!-- %-->

(Note the space after "^notempty: " if you don't have that space, ^empty: will always be TRUE)

 

You could do the same thing with ^preg_match: and ^eq e.g.

<!--%ds__Name^preg_match:[sS]mith:-->%
This stuff is shown only if "Smith" or "smith" is found in  $ ds_Name %
%ds__Name^preg_match:[sS]mith:<!-- %-->

or

<!--%ds__Name^eq:Mr Smith:-->%
This stuff is shown only if % ds_Name % exactly matches "Mr Smith"
%ds__Name^eq:Mr Smith:<!-- %-->

This is an ugly but effective solution. As it shows/hides the stuff you need but that stuff is always sent in the HTML.

 

One problem with this technique is that it can be broken if there are HTML comment tags inside %ds_Name%

 

(If there was a way to strip HTML comments from the page before it's sent then this solution would invisible to the end user)


(Tim Davison) #5

(If there was a way to strip HTML comments from the page before it's sent then this solution would invisible to the end user)

 

Would ^strip_html work in this case?


(Evan Wills) #6

&nbsp;


 
Would ^strip_html work in this case?


&nbsp;


Hi Tim


Yes ^strip_html is what I use in this case (when I can).

Sometimes, though, I need the full HTML which is why it can be so fragile.