Conditional keywords Display


#1

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!


(Nic Hubbard) #2

Have you tried something like:

%begin_globals_asset_url^contains:url-test%

YES

%else_asset%

NO

%end_asset%

(TT) #3

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>
@@-->

(Nic Hubbard) #4

If you are wanting to use the asset ID you could do:

%begin_globals_asset_assetid^eq:171524%

YES

%else_asset%

NO

%end_asset%

(Steven Kent) #5

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