Hi there
I am trying hide a section of the page depend on the URL where is nested, what’s the best solution?
any example would be great!
Hi there
I am trying hide a section of the page depend on the URL where is nested, what’s the best solution?
any example would be great!
Have you tried something like:
%begin_globals_asset_url^contains:url-test%
YES
%else_asset%
NO
%end_asset%
Like Nic said above for the url.
If you want to do it for specific pages only without having a certain word in the url, you can use ssjs.
e.g. something like the below
<!--@@ Allows for multiple random asset id's to display/hide stuff depending on if it matches the case
<script runat="server">
switch ('%asset_assetid%') {
case '65318':
case '154668':
print('<p>Statement is true</p>');
}
</script>
@@-->
If you are wanting to use the asset ID you could do:
%begin_globals_asset_assetid^eq:171524%
YES
%else_asset%
NO
%end_asset%
Could this be extended for multiple pages / assets? Thinking of nesting a single asset with conditional content display
Something like:
If asset is #123456, display The cat in the hat came back
Else if asset is #654321, display Green eggs and ham
Otherwise, display Horton hears a who
The last part is problematic. If I use
%begin_globals_asset_assetid^eq:123456%
The cat in the hat came back
%end_global% %begin_globals_asset_assetid^eq:654321%Green eggs and ham
%else_global%Horton hears a who
%end_global%I get this on #123456
The cat in the hat came back
Horton hears a who
and this on #654321
Green eggs and ham
Horton hears a who
Hi @kentst,
Could just be a typo but don’t forget to add ‘s’ to the end of your keywords - %end_globals%, for example.
You could just capture the whole thing in one IF … THEN … ELSE:
%begin_globals_asset_assetid^eq:123456%
<p>The cat in the hat came back</p>
%else_begin_globals_asset_assetid^eq:654321%
<p>Green eggs and ham</p>
%else_globals%
<p>Horton hears a who</p>
%end_globals%
… you could continue to extend the middle bit ( %else_begin_globals
… ) to add additional, hard coded asset IDs.