Using conditions to nest in different content


(Charlotte Westney) #1

Hi everyone,


I have a situation that seems like it should be easily achieveable, but I just can't get it to work.

Situation is this:



If page metadata = Yes, nest in asset list A

If page metadata = No, nest in asset list B



(page metadata is always either Yes or No).



I have a paint layout applied to the page, with a conditional keyword set and can get that to output different bits of text, eg



%beginA%

My metadata is A

%endA%



%beginB%

My metadata is B

%endB%





But I can't get those conditions to work around nested content.

EG:

%beingA%

Nested content div to bring in Asset list A

%endA%





I've also tried setting up another paint layout, which simply shows the asset content if the metadata condition is true, and then applied that to the nested content. But that doesn't work either. EG



Nested content div, brings in Asset list A, using paint layout 'showA'



'Show A' paint layout has conditional keyword, and default content as:

%beginA% %asset_contents% %endA%







So, how do I go about getting this seemingly simple set-up to work? There must be a way, right?!



Thanks!

Charlie.


(Nic Hubbard) #2

Sadly, you can't use conditional keywords in different content divs, so trying to wrap them around nested content work work. They need to be used in the same div.


(Charlotte Westney) #3

Hi Nic,


Yup, its a shame that they don't work across divs!

How can I use it across one div, if that div is a nested content type? Or is there a way to nest in content using a raw html div and a keyword that I don't know about yet?! (I'm sure they're are lots of those! :rolleyes: )



Thanks,

Charlie


(Nic Hubbard) #4

[quote]
How can I use it across one div, if that div is a nested content type? Or is there a way to nest in content using a raw html div and a keyword that I don't know about yet?! (I'm sure they're are lots of those! :rolleyes: )

[/quote]



You could perhaps try to use the new %globals_asset_contents:165% keyword if you are using 4.2.2 :slight_smile:



See: http://matrix.squizsuite.net/patches/4.2.2


(Dave Letorey) #5

Hi Charlie


Nic is right the way to do this is using the %globals_asset_contents:xxxx% keywords, we've been afetr this keyword for yonks (ages) and finally got it in 4.2.2.



Version 4.2.3 came out yesterday, so have a word with your Account Manager and whamo it'll work just as you've always wanted



Dave


(Dan Simmons) #6

If you don't have %globals_asset_contents:XXX%, could one work around this using snippets?


Snippets can be nested in a page using %globals_snippets_XXX% and they are just bodycopy DIVs, right? Which means a snippet could actually just be a nested content DIV.



Would that work?


(Steve Jordan) #7

[quote]
If you don't have %globals_asset_contents:XXX%, could one work around this using snippets?



Snippets can be nested in a page using %globals_snippets_XXX% and they are just bodycopy DIVs, right? Which means a snippet could actually just be a nested content DIV.



Would that work?

[/quote]



I can confirm Dan's approach is viable, we do it in a few places to achieve exactly what you're after.



Steve


(Charlotte Westney) #8

Thanks for all the great advice guys!
I don't have version 4.x yet, and won't do til the end of the year once we've migrated all our sites in, (then we'll have a big upgrade, get the Squiz Suite installed and start playing with all the new features) so I'm going to try the snippet approach and see if that works!



Not used snippets before, but looks pretty straightforward…

Charlie





-----------------------------------

Update:

The snippet keyword worked a treat!



So full code is now:



%begin_conditionname%

%globals_snippet_12345%

%else_conditionname%

%globals_snippet_12346%

%end_conditionname%



(note its 'globals_snippet' not 'globals_snippets' in keyword).





Big thanks to all of you for your input, this forum is great!



C ;o)


(Nic Hubbard) #9

Great solution to use Snippets!


(Kelvin Yong) #10

[quote]
If you don't have %globals_asset_contents:XXX%, could one work around this using snippets?



Snippets can be nested in a page using %globals_snippets_XXX% and they are just bodycopy DIVs, right? Which means a snippet could actually just be a nested content DIV.



Would that work?

[/quote]



Does the XXX value has to be hard coded or can it be replaced by feeding another keyword replacement?



What I'm after is something like %globals_asset_contents:%asset_metadata_relatedAssetId%%. Is that possible or am I just imagining and wishing it could?


(Dan Simmons) #11

[quote]
What I'm after is something like %globals_asset_contents:%asset_metadata_relatedAssetId%%. Is that possible or am I just imagining and wishing it could?

[/quote]



You can't nest keywords within keywords at the moment, but in your case above you should be able to do this:


    
    %asset_metadata_relatedAssetId^as_asset:asset_contents%


Though I haven't tested that...

(Smallwooda) #12

Is the %globals_asset_contents:xxxx% code limited to certain asset types?


I'm trying to nest a google map based on a metadata value using the regexp condition in a paint layout.



When I use the %globals_asset_contents:xxxx% with an image, it works perfectly but it doesn't seem to work with a google map.


(Ryan Archer) #13

%globals_asset_contents:165% YES YES!

Thank you! 

 

Doing conditions around nested content has been bugging me for like 3-4 hours!


(Nic Hubbard) #14

%globals_asset_contents:165% YES YES!

Thank you! 

 

Doing conditions around nested content has been bugging me for like 3-4 hours!

 

I would make sure to use %globals_asset_contents_raw:123% otherwise it will pull in the paint layout for that asset.


(Ryan Archer) #15

Hi Nic, yes it's a GOOD thing that I actually want the paint layout to come in for that asset ;)