Blog Sections Open

Passing Parameters into Chunks with parseChunk in Evolution CMS

A reusable parser pattern for avoiding dozens of one-off helper snippets when you only need to inject values into a chunk template.

Evolution CMS does not offer Revolution-style chunk parameters out of the box, so teams often end up writing many tiny snippets whose only job is to substitute a few placeholders in a chunk. That gets noisy very quickly.

The cleaner idea

Create one small helper snippet that calls $modx->parseChunk() and passes all snippet parameters into the chunk as placeholders.

<?php
return isset($ChunkName)
    ? $modx->parseChunk($ChunkName, $modx->event->params, '[+', '+]')
    : '';
?>

Example usage

[!parseChunk? &ChunkName=`form` &username=`Agel_Nash` &mail=`parsechunk@example.com`!]

Inside the chunk, placeholders such as [+username+] and [+mail+] are filled automatically.

Why this matters

  • one generic helper replaces many near-duplicate snippets
  • templates stay readable
  • parameter passing becomes predictable across the project

This is one of those small parser patterns that makes a legacy Evolution CMS codebase much easier to maintain.

Newer post

Using jquery-timeago with Evolution CMS Dates

A lightweight frontend enhancement for showing relative publication times such as “5 minutes ago” using Evolution CMS date output and the jquery-timeago plugin.

Older post

Setting a Default Value for a Date TV in Evolution CMS

A guide to the common “current date by default” problem for Date TVs and why naïve @EVAL attempts often fail.