I have big problem in my template, can someone help to understand what’s wrong?
- I have simple pages collection, like this:
<?php $news = $site->find("news")->children()->listed(); ?>
- I go thru them in foreach:
<?php foreach ($news as $news_item) : ?> ... <?php endforeach; ?>
- I have field
$news_itempage object, and can get it with no problem like this:
<?= $news_item->linkto_theme(); ?>
This field in blueprints is simple multiselect field, where I selecting other pages to “linking them” to my news page.
It returns other page ID for me, like
So there is I falling in troubles:
a) there is no way to get "label of this
otherpage value, because it page’s ID, not blueprint value.
b) Ok, I can use API and get this page title by using somtehing like
c) It works perfect, but I need it in “dynamic” - there is more than one
news page in my collection, and there is
somethirdpage values in next collection page objects.
d) Logically I can use something like this:
is an argument (other page’s id) getted “dynamically” from field value,
but it works ONLY ONCE!
When I increase limit to 2+, there is no error, but dump returns me only FIRST page’s dump in collection.
e) And there is other problem -
returns me a Page object, but
wont work too on more than one page collection!
It returns me
Kirby\Cms\Field Object ( [title] => My Other Page Title )
when I set collection limit to 1, but throws me an error when I set collection limit to 2+ !!!
Error Call to a member function title() on null
I broke my brain, please someone help me, what I did wrong?
I think this is simple logical way - go thru pages collection, get some field values as other page’s ids and get titles from this ids and print it to template etc. ?!
Thank you very much.