Jump to content

"Trying to get property of non-object" after enabling language support


DarsVaeda
 Share

Recommended Posts

I enabled language support and now I get "Trying to get property of non-object" for lines like:

<p><?= $page->text ?></p>

The content is still available in the backend. On another page I get text from the frontpage with:

<?php
$somepage = $pages->get(1);
?>
...
<p><?= $somepage->text ?></p>

This outputs the text although on the frontpage it doesn't. I also do this on the header. On the frontpage I added some fields that are thus "shared" among all pages the content fails with the error for `<?= $page->text ?>` but not for `<?= $pages->get(1)->text ?>`.

On a third page everything works as expected :huh:

All three pages have different templates.

Additionally if the field is wrapped with frontend editing like so:

<p><edit text><?= $page->text ?></edit></p>

The page source will end up like this:

<p></edit></p>

Before having to dig deep into this:

Any idea what it could be? I var_dumped $page and that gives an object.

Link to comment
Share on other sites

The problem is that although the data is available in the backend, for some reason the data field of the page does not have the fields (+data) when displaying the page.

Haven't found the reason though yet. Maybe some connection got lost in the db while switching from single to multilanguage mode?
But well then the data wouldn't be available with "<?= $pages->get(1)->text ?>" either, wouldn't it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...