I'd like to include an optional Javascript file/or group of files in my design file, which I can enable or disable in a customisation. I understand print="no" will allow you to specify this but it seems to be limited to design tags, in which there's no "generic content" option.
I understand the nest content tag will probably do what I'm after, but is there a better way?
[quote]
I'd like to include an optional Javascript file/or group of files in my design file, which I can enable or disable in a customisation. I understand print="no" will allow you to specify this but it seems to be limited to design tags, in which there's no "generic content" option.
I understand the nest content tag will probably do what I'm after, but is there a better way?
[/quote]
The asset lineage design area will do what you're after. It's a bit of a dodge way of doing it but the only real solution if you need to write code directly into the Parse file (otherwise, use nested content areas).
For example:
Another method (which would also reduce the number of Design Customisations required) is to use metadata (via an "Internal" metadata schema). Create a metadata field called "javascript.enabled" which can be set to "true" or "false" then do something like:
You could move this functionality to an external JS file if required.
Paint layouts also provide an additional feature for conditional display. Conditional keywords is a screen available on the type formats bodycopy for paint layouts. When you configure this (there are alot of conditions you can choose, you may potentially want the keyword regexp condition to do something similar to Daniels example) you get some %begin%, %else% and %end% keywords generated for that condition.
Your bodycopy may look something like:
%begin_content%
%asset_contents%
%else_content%
%end_content%
Then create a page to hold the content of your javascript tag:
And apply the paint layout to it.
The page you can then nest into your design and the content of that page will show based on the conditions you set in the paint layout.
I'm approaching a similar problem: I've got a three-column design with arbitrary content in each column. I want to show or hide columns and add a class to the body, so that I can use one, two, or three column layouts without having three designs.
Approaches I've considered:
[list=1]
[*]Using a show_if design area and keyword_regexp to match a piece of metadata that toggles columns on or off. (Not ideal because it involves non-semantic metadata on every page in the system.
Does anyone have any suggestions for a better way to do this? I've pored over the docs, but nothing's really jumped out at me.
Cheers,
Ash.
[quote]
I'm approaching a similar problem: I've got a three-column design with arbitrary content in each column. I want to show or hide columns and add a class to the body, so that I can use one, two, or three column layouts without having three designs.
Approaches I've considered:
[list=1]
[*]Using a show_if design area and keyword_regexp to match a piece of metadata that toggles columns on or off. (Not ideal because it involves non-semantic metadata on every page in the system.
Does anyone have any suggestions for a better way to do this? I've pored over the docs, but nothing's really jumped out at me.
Cheers,
Ash.
[/quote]
Hi Ash,
if you don't want to use metadata or design customisations, you can always use tagging. Basically create 2 tags, and 2 other assets that can be anything really, comment or even data source assets. You would only need 2 as you the 3 column layout could be your default one and the other 2 would be overwrites.
So you tag 1 data source asset with one of the other tags, and you call the data source asset something like "col-1", do the same for the other data source asset and tag and call it "col-2".
Then you nest in a related asset listing into your design at whichever point you're printing the <body> tag or the surrounding <div> tag, and you let the related asset listing print this.
Then the type format of the related asset listing would print <div id="%asset_name%">, and obviously the no results body copy would print <div id="col-3"> as this would be the default value.
Then you simply just have to tag the sections of you site with the right tag that represents the col- class you want to use. It would cascade to new children and you can apply it on any root node.
That's the way I would do it if I wasn't using metadata or design customisations.
Hope that helps.
Cheers,
Bart
Thanks for the reply. I'm not averse to using design customisations or metadata, but I just want to know if there's a better way of doing it than what I've proposed.
In fact, I'd prefer to use customisations if I can. It's just the only way I can think of doing it is to have two customisable areas for each column (one for the column itself, and one for the class on the body,) which I'm not sure is right.
Ended up going with the design customisation route, and found I only needed one additional asset_lineage block as my design was mostly already done.
I had to make four customisations which I was a bit hung up on earlier, but now I realise it doesn't matter because you only have to apply the "design customisation" to an asset once rather than customise four items each time.
Thanks for the input, everybody. 