IF page has description{
<certain>
<html>[[*description]]</html>
</certain>
}This question has been answered by microcipcip. See the first response.
<html>[[*description:isempty:then=``:else=`[[*description]]`]]</html>
[[*description:isempty:then=``:else=`
<div class="description">
[[*description]]
</div>
`]]
<?php
/* MyDescription snippet */
$description = $modx->resource->get('description');
return empty($description) ? "" :
'<div class="description">'
. $description .
'</div>';
/* MyDescription snippet */
$description = $modx->resource->get('description');
return empty($description) ? "" :
$modx->getChunk('DesChunk', array('md,description' => $description));
<div class="description">
[[+md.description]]
</div>
[[If?
&subject=`[[*description]]`
&operator=`notempty`
&then=`
<div class="description">
[[*description]]
</div>
`]]<?php
$output = trim($input);
if (!empty($output)) {
if ($pos = strpos($options, " ")) {
$closetag = substr($options, 0, $pos);
} else {
$closetag = $options;
}
$output = "<{$options}>{$output}</{$closetag}>";
}
return $output;[[*description:tagwrap=`div class="description" id="idescr"`]]
{if username == "joe"}
<h1>Hey, Joe! Where were you Tuesday?</h1>
{if:elseif username == "bob"}
<h1>Hey, Bob! Thanks for the tickets!</h1>
{if:else}
<h1>Welcome to our site.</h1>
{/if}
(...)
I think that's pretty handy AND clean, I think it would be a good idea if MODx had something like that by default. Am I the only one?
Eoler:
Problem with that solution is: it's limited to one wrapper tag, or am I mistaken?
BobRay:
I prefer the "less efficient" but more separated approach, but it would be a hassle creating a custom snippet and chunk everytime I want to include some part of a document with wrapper html-tags.
Microcipcip:
That's the closest to what I was looking for, and closest to what I'm used to in ExpressionEngine.
EE has this:
{if username == "joe"} <h1>Hey, Joe! Where were you Tuesday?</h1> {if:elseif username == "bob"} <h1>Hey, Bob! Thanks for the tickets!</h1> {if:else} <h1>Welcome to our site.</h1> {/if}
I think that's pretty handy AND clean, I think it would be a good idea if MODx had something like that by default. Am I the only one?
Grtz
[[!switch?
&get=`[[+modx.user.username]]`
&c1=`joe` &do1=`<h1>Hey, Joe! Where were you Tuesday?</h1>one`
&c2=`bob` &do2=`<h1>Hey, Bob! Thanks for the tickets!</h1>`
&default=`<h1>Welcome to our site.</h1>`
]]
But I think a more versatile (and integrated by default) solution would be a nice feature for MODx.