I am using Modx 2.2.8 on Linux\cPanel
I am using the current version of Migx to create 3 boxes at the beneath the content area. I am calling the chunk in the content area of the page. Like so:
[[getImageList?
&tvname=`contactTV`
&tpl=`tpl_contactinfo`
&docid=`11`
]]
This is with the contact form.
Then in my main template I have the following for the 3 migx boxes:
<!--start content-->
<section id="content" class="clearfix">
<!--section top-->
[[*id:is=`5`:or:is=`6`:or:is=`7`:then=`<div class="grid_12">[[*content]]</div>`:else=`[[*content]]`]]
<!--end section top-->
[[$tpl_contentbottom]]
</section>
<!--end content-->
</div>
I would like to change the div for 3 pages with this [[*id:is=`5`:or:is=`6`:or:is=`7`:then=`<div class="grid_12">[[*content]]</div>`:else=`[[*content]]`]]
if the page is not 5,6 or 7 then put in the main content area with no div.
When I use this my contact page chunk disappears.
Can anyone help with a solution?
Thanks
Lisa
[ed. note: lchestnut last edited this post 13 years, 3 months ago.]
-
☆ A M B ☆
- 24,524 Posts
Indeed. I often amuse myself with shoehorning an entire site into one template, but it's usually far more trouble than it's worth. I do try to keep the templates to a minimum, but I usually end up with 6-8 templates for a fairly complex site.
Another method of doing something like what you have is to use chunks and a radio button TV for choosing between them. In your case, the default would be the radio button to load a chunk with just [[*content]] in it, while the other option would be for a chunk with the div container. Most resources will get the plain content. Then on resource #5, #6, #7 just select the other radio button.
Many thanks to both of you. I have been trying to keep things as simple as possible for my clients (tech savvy they are not). I will try these suggestions out.
I appreciate your time.
-
☆ A M B ☆
- 427 Posts
Quote from: Everettg_99 at Jul 05, 2013, 11:09 AMI agree with the others: chained output filters can be trouble.
I used to fall victim to this years ago. Once you understand each output filter is in effect potentially changing the original value to be handed off to the next filter it gets much easier.
Thanks all for your input. I am really trying to get the hang of the output modifiers. I just wish they were a little simpler to use. If I have more than one condition to satisfy then most times they havent worked. I will keep working with Modx and learning.
Thank you.
Lisa
-
☆ A M B ☆
- 427 Posts
Lisa there is always longhand:
<div class="[[*id:is=`5`:then=`grid_12`]][[*id:is=`6`:then=`grid_12`]][[*id:is=`7`:then=`grid_12`]]">[[*content]]</div>
or
<div class="[[*id:is=`5`:or:is=`6`:or:is=`7`:then=`"grid_12"`:else=`"someotherclass"`]]">[[*content]]</div>
Shawn's approach will be much faster. The problem with your original code is that the entire content of the page will be parsed twice, for no reason.
BTW, I would do it with a snippet snippet:
<div class="[[!GetClass]]">[[*content]]</div>
<?php
/* GetClass snippet */
switch($modx->resource->get('id') {
case '5':
case '6':
case '7':
$output = 'grid_12';
break;
default:
$output = 'someotherclass';
}
return $output;
-
☆ A M B ☆
- 24,524 Posts
The problem with output modifiers is that every condition is checked, even if the first one resolves to true. So if you have several options to your condition it evaluates every one of them, slowing things down. Jason pointed out one way of working around this, although I still don't quite understand exactly what it's doing. It involves embedding the conditional in the chunk or TV tags. I can't find the reference to this, though. Maybe somebody else knows what I'm referring to?