medienbaecker / kirby-modules

Plugin for modular Kirby websites
MIT License
73 stars 7 forks source link

Call to a member function find() on null #41

Closed alexanderhacke closed 4 months ago

alexanderhacke commented 4 months ago

Thanks for the great plugin!

I have a small problem and hope you can help me with it :)

In my module template I have the following request:

I get the following error message:
Call to a member function find() on null

Can you please tell me how I can access a page via a module?

Thanks a lot Alex

medienbaecker commented 4 months ago

It looks like there's something before the find() method you're calling and it's null. Do you use $module->find('forms') or $page->find('forms')? Where is the forms page located?

alexanderhacke commented 4 months ago

Hi Thomas, ups, sorry. Here is the full line i have in my modules template: <?php echo kirbytextinline($pages->find('forms')->company()) ?> The forms page is a unlisted site and located in the root.

When i place the line <?php echo kirbytextinline($pages->find('forms')->company()) ?> outside the modules template, everything works fine.

I hope you can help :)

medienbaecker commented 4 months ago

Ah, I see. Thanks for the full picture. Looks like the $pages variable is null. You can try $site->pages() or site()->pages() instead.

alexanderhacke commented 4 months ago

Juhuu, it works perfekt! Thank you so much :-)