Blog Sections Open

Skipping a Snippet on One Page Without PHx

A lightweight alternative to PHx conditions when you need a snippet to stop executing on one specific resource.

Old Evolution CMS projects often used PHx just to conditionally hide a snippet on one page. That works, but it adds parser overhead and can still execute expensive snippet logic before the condition hides the output.

The common example

A small cart snippet should appear on most pages but not on the full checkout page.

The PHx-style solution

[+phx:if=`[*id*]`:ne=`10`:then=`
[!Shopkeeper? &cartType=`small` &orderFormPage=`10`!]
`+]

Why that is not ideal

  • it depends on PHx
  • the parser does extra work
  • the snippet may still execute even when you only wanted to suppress output

The simpler snippet-level check

if (isset($hideId) && $hideId == $modx->documentIdentifier) {
    return;
}

Put that at the top of the snippet and pass &hideId where needed.

Why this is a good legacy pattern

It keeps the logic explicit, avoids extra parser stages, and works for far more than one cart snippet. The same idea applies to search widgets, recommendation blocks, banners, or other reusable snippet output.

Newer post

Using the First Content Image as a News Preview in Evolution CMS

A practical snippet pattern for deriving a preview image from article content when editors skip the dedicated image TV.

Older post

SEO Basics for Evolution CMS: Titles, WWW Canonicalization, Sitemaps, and 404s

A practical SEO checklist for older Evolution CMS projects covering page titles, menu titles, canonical host choice, XML maps, and other fundamentals that are often skipped.