Nest content inside conditional on paint layout?

Hi,


This doesn't seem to be working for me, so I just want to check whether it is actually possible…



Can you nest content within a conditional on a paint layout? I'm trying to display a nested asset list based on a condition, but it shows on every page. The condition definitely works as I use it elsewhere on the page and those elements (a different introductory paragraph, for example) only display where they're supposed to.



For example…



Div 1 (presentation: Raw HTML, content type: Raw HTML)

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

some content here



%begin_mycondition%

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



Div 2 (presentation: Raw HTML, content type: Nest Content)

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

NESTED ASSET LISTING

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



Div 3 (presentation: Raw HTML, content type: Raw HTML)

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

%end_mycondition%



some more content here

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



The paint layout is otherwise working as expected. I would just like to know whether or not this is supposed to work. I'm getting the impression you can't split a conditional over multiple divs, even if they are Raw HTML…?



I've also tried putting the %begin_mycondition% and the %end_mycondition% inside the actual asset listing but that made no difference (I didn't really expect that to work).



Thanks!



Margaret

I've done a bit more testing… I replaced the nested content div with another Raw HTML div and just plonked a paragraph in there and that displays on all pages too, so I'm gathering that conditions don't like being split across divs…


Is there another way to get a paint layout to conditionally display the contents of an asset listing? It's a single asset list I'm trying to nest, which uses dynamic parameters to display the children of the current asset. I only want it to display on certain pages though, according to the condition.



I'll use link values to achieve what I want to do if I have to, but I'm trying to avoid having to go back through all the pages, plus that won't be easy for the average editor to do in the future if new pages are added.



Apologies if there's some bleedingly obvious solution to this! I've got myself stuck.



Let me know if you need any further info.

If the condition is based upon a users membership in a user group, you could use two divs in your paint layout, with differing permissions?

Ah nice solution thanks, but unfortunately no, the condition is not based on permissions.


Ok, here's a bit more info about what I'm doing… :slight_smile:



I'm working on a new 'find us' section for the State Library of Tas. We have about 50 libraries in our network around the state. I've created a standard page for each library and their contact details, hours, etc are done in metadata and displayed using a paint layout. We've also got Google Maps embedded in each one, so the pages are looking pretty cool, if I do say so myself. :wink:



Some of the libraries are 'city libraries' and because they are bigger libraries, their pages can contain unique content (specific info to the library, links to related local organisations, etc), so that is just done on the standard page in normal WYSIWYG divs, and is displayed using the %asset_contents% keyword in the paint layout.



So far it all works fine, no problems. :slight_smile:



Most of the libraries, however, are 'branch libraries'. They are smaller and generally regional, and they all contain the same basic info about what services they offer. They also use the metadata and paint layout as they obviously all have different contact details and hours etc.



That also all works fine. :slight_smile:



However, SOME libraries (city or branch) have a 'What's on at X library' as a child page. This is from an existing structure so I have to keep it for now. It is being linked to from a section on each library page called 'Library information'.



In the case of the city libraries, which I set up first, this has been set up on the standard page as WYSIWYG content. It really needs to stay that way for them too as they're likely to have extra information in their 'Library information' section.



But I'd like to automate it for the branch libraries as there are a lot of them, and that link to the 'What's on' page would be the only thing not controlled by metadata on those pages…



So the asset listing seemed like the perfect solution as it displays a link to the 'What's on' page if it exists, but I can't really use that solution on the city library pages.



So, I basically want the nested asset listing to only display on Branch Library pages.



In the metadata there is a select option for whether it is a branch library or not - they just pick 'yes' or 'no'.



If it IS a branch library, a generic intro is displayed, and the email link says 'Email branch library' instead of 'Email %asset_name%. That works fine, as I want it to. Therefore I thought this condition would also work for the nested asset listing, but apparently conditions don't like being split across a couple of divs.



If this doesn't work it's ok, we'll either have to have the asset listing showing on every single page, and the city libraries will just have to settle for a rather generic asset listing which could display redirect links but not extra blurb, or I'll have to go through and mark the link values as 'branch' or something on each of the What's on pages. Like I said before, however, that's not something that the average editor would be able to handle down the track so it's not ideal. I'd like to get it all as automated as possible.



The other option is to put all this info in the metadata too, but that requires a knowledge of HTML tags (bulleted lists and links… eek, fine for me, but not the editors) and gets a bit messy.



I hope all that makes sense!




Hi Marg,


I believe you were right in thinking that it doesn't like being split across multiple DIVs. From what I can remember of Paint Layouts, the condition block (from %begin_condition% to %end_condition%) has to be contained within the one bodycopy container. This reduces the possibility that a condition is begun in one container but the user forgets to close it in another, which would cause logic problems. If they are not matched in the same bodycopy container, they are replaced with nothing.



Unfortunately, off the top of my head I can't think of any "quick" solutions at a paint layout level that would be able to help you put the condition into one DIV. Is there perhaps something you can do with the asset listing to be able to control it there? For instance, are the city libraries assured of having no child pages underneath, in which case you might be able to use the "No Results" bodycopy to blank this out? (I'm probably drawing a long bow here, though.)

Hi Luke,


Thanks for confirming that, and yeah it makes sense when you mention the possibility of logic problems.



That's a pity, but it's better to know - I can spend my time working out another solution rather than trying to achieve the impossible. :slight_smile:



Thanks again!




[quote]Hi Marg,



I believe you were right in thinking that it doesn't like being split across multiple DIVs. From what I can remember of Paint Layouts, the condition block (from %begin_condition% to %end_condition%) has to be contained within the one bodycopy container. This reduces the possibility that a condition is begun in one container but the user forgets to close it in another, which would cause logic problems. If they are not matched in the same bodycopy container, they are replaced with nothing.[/quote]

[quote]Hi Luke,


Thanks for confirming that, and yeah it makes sense when you mention the possibility of logic problems.



That's a pity, but it's better to know - I can spend my time working out another solution rather than trying to achieve the impossible. :slight_smile:



Thanks again![/quote]



It is something we are looking at trying to find a solution for, as it is not the only time it has come up.



Post back if you cant find a good solution - there are some other options potentially.

Hi


I’m half way through doing something similar I think if I understand you correctly (no idea if it works or not yet as I’ve had to abandon it for now to do some other stuff) so I thought I’d share my thinking / idea and see if you can adapt it.



It’s built on DB data sources and asset listings (as Luke suggests). You pass in the page ID to a DB data source that then construct an SQL query that looks for that page but only succeeds if it has a metadata value of ‘branch’. Something like



[font=“Courier New”]SELECT “assetid”,“fieldid”,“value”

FROM “public”.“sq_ast_mdata_val”

WHERE “assetid” = ‘%%pageid%%’

AND “fieldid” = ‘12345’

AND “value” = ‘Branch’[/font]



Where the %%pageid%% is set on the DB source dynamic input screen and the fieldid is that of the metadata field. You can then base an asset listing on the DB source and it if evalutes true (ie is a branch) do stuff with the results bodycopy or if not the no results bodycopy. And in thoery you should be able to embed this asset listing in the paint layout.



The bit I’ve gotten stuck at is the chain of passing in the assetid to the DB source. i.e. I can get the asset listing to work passing in a GET variable directly, but when I embed it in the paint layout it always evaluates false (I assume as the assetid isn’t being passed correctly). Tried setting it to current asset asset id on the Dynamic input screen and passing in the assetid as a GET variable when I nest it. Both don’t work.



maybe one of the squiz guys can fill in the gaps? Either way hope this helps…



cheers



K


I am pretty sure that you need 3.18.5 for this, which allows you to pass a get/post parameter to nested content.

yup - on 3.18.6 but not working...

K

[quote]yup - on 3.18.6 but not working…


K[/quote]



Sorry, should have ready your post closer. :slight_smile: