I changed title and path of an entry. Now, the whole page collapsed and does not load anymore. What happened and how can I fix this issue?
You probably called this page via id at some point without checking if that page exists.
Does reverting the change help?
Is debugging active? Whatβs the error message?
Thanks. I downloaded the entire site. Locally, it works. After editing, I will upload the entire site replacing the old one.
As @stffr already pointed out correctly, when working with objects, you always have to check if they exists before you call a member method. That is a very important rules to internalize:
For example, instead of doing this (big no-no)
<?= page('blog/my-post')->url(); ?>
Always do it like this
<?php if ($p = page('blog/my-post')) {
echo $p->url();
}
?>
In PHP 8, you can also do it like this (when the context allows)
<?= page('blog/my-post')?->url(); ?>
1 Like