Blog Sections Open

Creating a Simple Name Library for Reusable Text in Evolution CMS

A lightweight pattern for storing small reusable text fragments in a chunk and returning them through a snippet instead of hard-coding them everywhere.

Projects often have small text fragments that appear in many places: phone numbers, company names, copyright lines, labels, and short legal notes. This article proposed a very simple “name library” approach for cases where a full settings layer feels excessive.

Chunk-based storage

Create a chunk named names and keep key-value pairs there, one per line:

copyright==Company Name
year==2012
phone==777-77-77

Lookup snippet

<?php
$godChunk = $modx->getChunk('names');
$paramLines = explode("
", $godChunk);
$paramArr = array();
foreach ($paramLines as $line) {
    list($param, $ppid) = explode('==', $line);
    $paramArr[$param] = $ppid;
}
return $paramArr[$is] ?? '';

Usage

[[name? &is=`copyright`]]

The original note also added a small manager shortcut to open the chunk quickly from the dashboard. It is a modest pattern, but still useful when you want centralized editable text without introducing another layer of complexity.

Newer post

Using YAMS on Nginx in Evolution CMS

A minimal Nginx rewrite example for older YAMS-based multilingual Evolution CMS projects using language prefixes such as /ru/ and /en/.

Older post

Removing a Section Alias from Evolution CMS URLs

A legacy routing guide for cases where you want cleaner nested URLs without destroying the document tree structure in the manager.