Handling pages

This page is about handling pages.

Table of contents

Reading configuration information from the config file

Sometimes, you want to read information from your configuration. This can be done using the Config class.

Access this object using the DI class:


use Kiwa\DI;

$config = DI::getConfig();


Searching and filtering pages

If you want to search for specific pages and/or filter them, Kiwa provides you the PageList class. It works like this:


use Kiwa\Config\Page;
use Kiwa\Page\PageList;

$pageList = PageList::create()

/** @var Page $page */
foreach ($pageList as $page) {

In this example, we are searching for all pages defined with a language code de and being defined as child pages of the page blog. The $pageList contains then an array of Page objects.

Available filters

Currently available filters are:

  • hasLanguageCode(string $languageCode)
  • isChild()
  • isNoChild()
  • isChildOf(string $parentPageFileName)
  • hasPageName(string $pageName)
  • hasDynamicChild(string $dynamicChildName)
  • usesFileName(string $fileName)

Page linking

There are multiple ways of linking between pages and generating URLs to do so. You can

  • Generate a URL based on the page's file name using the URLFromFile class.
  • Generate a URL out of a Page object using the URLFromPage class.

You can read more about generating URLs under the section URLs and links.