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.
Answer
Errors and blank pages
"Call to a member function on null" in a template
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
- A Smarty template seems to skip a PHP function I called
- A Twig template errors on an undefined variable that used to render empty
- Output is double-escaped, or not escaped at all, after a template was ported
- "Method X does not exist" when rendering a record
- "Property X does not exist" from a shorthand area call
Was this page helpful?
Your answer goes to the docs team.