Custom fields on parent page
- Misteric
- Ssr. Bludit
- Posts: 16
- Joined: Mon Aug 08, 2022 2:55 pm
- Has thanked: 4 times
- Been thanked: 6 times
Hi Bayerberg,
1. List all the pages.
2. Check first if it's a parent page.
3. Afterwards you check if it has a custom field...
You can do something like that:
Hope it's helpfull ,
Misteric
1. List all the pages.
2. Check first if it's a parent page.
3. Afterwards you check if it has a custom field...
You can do something like that:
Code: Select all
<?php
// Page number of the paginator, the first page is 1
$pageNumber = 1;
// The value -1 tell to Bludit to returns all the pages on the system
$numberOfItems = -1;
// Only get the pages with the satus published
$onlyPublished = true;
// Get the list of keys of pages
$items = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
foreach ($items as $key) {
// buildPage function returns a Page-Object
$page = buildPage($key);
// The variable $page is an Page-Object
if ($page->hasChildren())) {
echo 'The page is a parent page';
if($page->custom('ZZZ')) {
echo 'You can sleep now on your 2 ears';
}
} else {
echo 'The page isn't a parent page';
}
}
?>
Misteric