Jump to content

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

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:

$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:


Before having to dig deep into this:

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

Share this post

Link to post
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?

Share this post

Link to post
Share on other sites

So I couldn't figure it out in a reasonable time, so I started fresh from a backup before switching to multi-languages and switched again.
This time it works. So I guess something went wrong whilst installing the appropriate modules.

  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mithlesh
      Changing it to null
    • By Mithlesh
      Hi, I have one URL - writerrelocations.com/contact-now/

      I have one issue where my header Image is appearing again after the contact form, for your reference:

      I have checked my processwire template section where have not added any Image field besides Header Image, attaching the same for the reference:

      PLEASE help me to get rid of the image below contact form

      Waiting for the swift response!

    • By EyeDentify
      I have been experimenting with the new $page->meta() method and find it useful.

      Once i figured out that the data i "save" with it is tied to the page where i called the method from.

      So this is not obvious at least not for me in the documentation:
      So i just wanted to share that revelation with the community so you don´t get as confused as i was.

      Happy Coding Everyone.
    • By stanoliver
      In the new page-meta-method (https://processwire.com/blog/posts/pw-3.0.133/#comments) there is an example how to ouput "world". 
      Could may someone give me a snippet of code so that the output is one of the colors (red, green, blue).
    • By snobjorn
      Here's my Norwegian language pack for ProcessWire. I've been adding translations over some time, to suit my own projects users needs.
      Last updated:
      2019/06/19 (June 19, 2019)
      Not yet complete. Translations that non-superusers will see is prioritized.
      Translated using:
      ProcessWire 3.0.133 dev
      Number of files:
      189 wire files and 95 site files – ranging from just started to completely translated. The site files includes translation some free and some pro modules, see the complete list in the README.md at GitHub.
      Available at GitHub:
  • Create New...