I'm Searching for pages() in kirbytext

I’m migrating a Kirby 1.x WebSite to 2.x.

This old Website uses the pages() object in kirbytext to have access to all pages from the whole website to filter special content. How can I have access to all pages in Kirby 2.x Kirbytext? It is important to have the access in Kirbytext. The pages() object is working great in template and controller.

I don’t really get what you mean by “in Kirbytext”? Is that a custom Kirbytag you are talking about? Could you post your original K1 code?

The old solution was inside of ‘kirbytext.extended.php’. And the news element uses this fix:

function news($params) {
  global $site;
  $pages = $site->pages();
  $page = $pages->active();
  ...

Inside of the text() ist looks like this:

(news:poetryslam type:event headline:Headline vor the next Event)

Now it’s called kirbytags under the topic ‘Extending Kirbytext’

$site->index() is probably what you are looking for http://getkirby.com/docs/cheatsheet/site/index

1 Like

It seems that the following code-snippet works

site()->index()->find('/projects')->children()...

Thanks for you hint

site()->index() is too much in this case. It will create an index of the entire site first, which means scanning all pages, subpages, etc. What you probably want is

page('projects')->children()
1 Like