Conditional keywords in asset listing


(Oliver Kass) #1

Another week another keyword puzzle...I've got an asset listings on a beta site that prints a "promoted" label against listing content via metadata. Content editors can select Yes (option key 1) No (option key 0) via the Asset.Promoted metadata field to get this to print on the front end.

 

I'd like to be able to add a class to the promoted asset links so we can track accurately via Google Tag Manager. Was thinking conditional keywords should work for this. Something like this was my thinking but I can't get it to work so far....

 

%begin_asset_metadata_Asset.Promoted^eq:1:1:0%
  <p><a href="%asset_url%" class="promoted-article">%asset_name%</a><br>
  %asset_metadata_Asset.Description%
  <span class="label label-promoted">Promoted <i class="fa fa-file-text-o"></i></span>  
%else_asset%
  <p>
  %asset_name_linked%<br>
  %asset_metadata_Asset.Description%
  </p>
%end_asset%
 
Have tried a few combinations but only get a blank listing or the else asset code...using Matrix 5.0.4.1
 
Another option I was playing with was this. It almost works but I can't get the keywords in {} to print properly:
 
<p>
  %asset_metadata_Asset.Promoted^eq:1:<a href="{asset_url}" class="promoted-article">{asset_name}</a>:{asset_name_linked}:%<br>
  %asset_metadata_Asset.Description%
  %asset_metadata_Asset.Promoted^eq:1:<span class="label label-promoted">Promoted <i class="fa fa-file-text-o"></i></span>:%
</p>
 
Thanks
 
Oli

(Peter McLeod) #2

Hi Oli

 

try adding the replace_keyword modifer before your eq one:

 

%asset_metadata_Asset.Promoted^replace_keywords:eq:1:<a href="{asset_url}" class="promoted-article">{asset_name}</a>:{asset_name_linked}:%<br>

 

Thanks

Peter


(Oliver Kass) #3

Cheers Peter,

 

That's working. Sometimes the simple solutions are the best.

 

Still think that the conditional keywords solution should work as well but at least I have something that works now.

 

Oli