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.

"Call to a member function on null" in a template

A chain went through an empty relation: getParent() on the root page, getAreaRecord() on an empty area, getShareImage() with none set, getActiveRevision() on a record that has none, _menu->get() for a renamed menu. Assign the intermediate value and test it before calling anything on it. The frontend returns blank objects for images, components, widgets and raw content, so those chains are safe; files, records and relations return nothing, and are not.

Template code
{$parent = $page->getParent()}
{if $parent}<a href="{$parent->getFullPath()}">Up</a>{/if}
{% set parent = page.getParent() %}
{% if parent %}<a href="{{ parent.getFullPath() }}">Up</a>{% endif %}

More in Errors and blank pages

  1. A Smarty template seems to skip a PHP function I called
  2. A Twig template errors on an undefined variable that used to render empty
  3. Output is double-escaped, or not escaped at all, after a template was ported
  4. "Method X does not exist" when rendering a record
  5. "Property X does not exist" from a shorthand area call

Was this page helpful?

Your answer goes to the docs team.