A straightforward way to list specific pages on a template, especially when you need to distinguish between static and dynamic pages, requires understanding how Bludit handles page types and how to manipulate the API to filter pages based on your requirements.
Since you want to display regular pages on your static 'Projects' page and bypass the standard behavior that lists child pages, you'll need to modify how you fetch and filter the pages. Here’s a solution that uses Bludit's built-in functions to retrieve all pages and then filter out static pages:
Step 1: Fetch All Pages
First, get all pages, then you can filter them based on the type of the page. In Bludit, static pages are typically differentiated by their type, and you can check this using the `type()` method on a page object. Regular pages usually don't have a specific type set (or it could be 'published').
Step 2: Modify Your 'projects.php' Template
You need to adjust your `projects.php` to include a loop that filters and displays only the regular pages. Here’s how you could write it:
Code: Select all
<?php
// Get all pages
$allPages = $pages->getList();
// Loop through all pages
foreach ($allPages as $pageKey) {
// Get the page object
$page = new Page($pageKey);
// Check if the page is not static
if ($page->type() !== 'static') {
echo '<h2>' . $page->title() . '</h2>';
echo '<p>' . $page->content() . '</p>';
}
}
?>
This script does the following:
- `$pages->getList();` fetches keys of all pages.
- It then iterates through each key, instantiates a page object, and checks the type of each page.
- If the page is not static (`$page->type() !== 'static'`), it outputs the title and content.
This approach should effectively list all non-static pages in your 'Projects' page template. If you have any additional plugins or themes that modify standard page behaviors, you might need to adjust the code to accommodate those changes.