Quote from: BobRay at Jun 17, 2018, 05:44 AMStuff like this is infinitely faster and more reliable in PHP, and not very complicated:
(I'm guessing at what you want -- feel free to clarify)
/* SomeSnippet code */
$output = ''
$docId = $modx->resource->get('id');
if ($docId == 12 || $docId == 22) {
$output = 'something';
} else {
$output = 'something else';
}
return $output;
I'm trying to add some schema codes into our website, I created a chunk named XJTLU_Schema, and call this chunk inside site.head chunk.
In this XJTLU_schema chunk, I set some condition to add schema codes according to different page template, for example,
[[*template:eq=`28`:then=`
<script type="application/ld+json">
{
"@context": "
http://schema.org",
"@type": "Person",
"name": "[[+sedona.name]]",
"honorificSuffix": "[[+sedona.highdegree]]",
"jobTitle": "[[+sedona.rank]]",
"description": "[[+sedona.bio]]",
"image": "[[+sedona.image]]",
"address": "[[+sedona.office]]",
"email": "[[+sedona.email]]",
"telephone": "[[+sedona.phone]]"
}
</script><!--Schema for staff-->
`:else=``]]
[[*template:eq=`23`:or:is=`24`:or:is=`37`:then=`
<script type="application/ld+json">
{
"@context": "
http://schema.org",
"@type": "EducationalOrganization",
"name": "[[*longtitle]]",
"description": "[[*content]]",
"address": "[[*contactAddress:nl2br]]",
"email": "[[*contactEmail]]",
"telephone": "[[*contactPhone]]"
}
</script><!--Schema for department,centre & research insitution-->
`:else=``]]
I only need to identify some key templates with different types, such as person, organization, event.....But for the other pages, I don't want to type the template ID one by one, I think if it could has some code like "else" to apply one all the other pages.