Troubleshooting · Developer docs

Troubleshooting

Grouped by symptom, never by module, because the person with the problem does not know which module has it. One hundred questions across ten pages, each answered with the causes in the order they usually turn out to be true.

Symptom 6 questions

Templates and engines

Six questions about which engine a site runs, why a copied snippet fails, and where variables go across inheritance, includes and shared partials, with the answers verified by rendering.

The engine is a site-wide setting and both engines get the same records, layouts and helpers. The questions that come up are about which one you have, and about scope, which the two handle almost identically.

Which engine is this site using

Open any template. {$page->getName()}, {if} and {foreach} are Smarty; {{ page.getName() }}, {% if %} and {% for %} are Twig. The extension proves nothing, since Twig sites usually keep .html. The setting behind it is Globals.template.engine, Smarty by default; a Twig site sets it in the .settings.json file at the root of its site folder. There is no admin screen for it. More in two engines, one platform.

Open this answer on its own page →
A snippet from the documentation does not work in my templates

It is for the other engine (every page here shows both, one after the other). Then: the record arrives under a different name on your route (page, post, product, a custom entity's identifier; record is set on every record page); the method is not on your record's response model (the Entities reference lists each); a Smarty modifier form of a PHP function, which the policy refuses; or the snippet assumes a setting, such as picture tags, that your site has off.

Open this answer on its own page →
A variable assigned before the inheritance tag does not reach the parent

It does, in both engines, as long as it sits at the top level of the child, before or after the extends tag and outside any block; rendered through the platform's own Smarty and Twig, the parent sees it everywhere. What does not reach the parent: an assignment inside a block, which Smarty exposes only after that block has rendered and Twig never; an assignment made inside an included partial, which stays in the include unless Smarty's scope='parent' is used; and a value the parent reads in a component rendered with getHtml(), which sees no template variables at all. For the last two, use _templateContext.

Open this answer on its own page →
A variable set inside an include does not survive outside it

By design in both engines: an included partial sees the caller's variables and its own assignments stay inside it. Smarty gets a value out with {$seen = true scope='parent'}; Twig cannot, but the platform's set also stores the value in _templateContext, where the caller reads it. The context works the same in both and is the portable choice.

Open this answer on its own page →
Translation works in one site and not another

The other site has no XLIFF file for that domain and language under translations/, so the key prints itself. Then: the call names no domain and falls back to the admin interface's domain; the interface language is chosen from the cdna_locale cookie, then the account default, then the browser, so a site that never sets the cookie shows the default language; or the site is Twig and the templates use a Smarty modifier, where Twig needs __.translate(key, params, domain).

Open this answer on its own page →
A partial shared between two page types sees different variables in each

The record arrives under a different name on each page type, and a Smarty partial sees everything in the caller's scope, so a partial reading $page works on pages and reads nothing, or an unrelated variable of the same name, elsewhere. Pass the record under an agreed name (item=$post) and read only that; in Twig, include with only so the partial sees nothing else.

Open this answer on its own page →
Go deeper

Was this page helpful?

Your answer goes to the docs team.