a cute full body pagedoll drawing of me a bald white feminine individual with heart shaped glasses and face tattoos cuddling a black and white longhaired cat
† Posted on . Tagged with: # .

Creating An Automatically Updating Sitemap In PureBlog

I recently switched from PureBlog to Chyrp, but here are my old tutorials.

I altered THIS CODE SNIPPET by David Carr for it.

Basically, this takes a list of the files in your pureblog/content/pages directory and retrieves it for the page with its title. Note that I'm using my dockerized version so please edit accordingly. When I learn more PHP, I will be updating this with categories and alphabetical sorting. For now though:

  1. Make a file called sitemap-auto.php in content/includes/

  2. Make a custom route in settings

/sitemap-auto | /content/includes/sitemap-auto.php

  1. Copy the code below or here

require PUREBLOG_BASE_PATH . '/includes/header.php';
render_masthead_layout($config, ['page' => null]);

?>

<main>
<h1> Sitemap</h1>

<?php

$directory = '/var/www/html/content/pages/';

$files = scandir($directory);

echo "<ul>";

foreach ($files as $file) {
    if ($file !== "." && $file !== "..") {
        $name = pathinfo($file, PATHINFO_FILENAME);
  $path = $directory . '/' . $file;
    $contents = file_get_contents($path);

       preg_match('/^title:\s*(.+)$/m', $contents, $matches);

    $title = $matches[1] ?? pathinfo($file, PATHINFO_FILENAME);

    $url = '/' . pathinfo($file, PATHINFO_FILENAME);

    echo '<li>πŸ›Έ <a href="' . htmlspecialchars($url) . '">'
        . htmlspecialchars(trim($title))
        . '</a></li>';
}
}
echo "</ul>";
?>

</main>
<?php render_footer_layout($config, ['page' => null]); ?>
</body>
</html>
  1. Put it in /content/includes/sitemap-auto.php

You're done :)

This will automatically update when a new file is in the pages list.

pagedoll (c)
site button
[email protected]
Webrings and such!
Quaker Ring
Previous Next
| computer popup window graphic with a double venus symbol and it says femslash fans online |
MY femslash OTP is...
πŸ’ž NAHLA X ANISHA ! πŸ’ž
previous random next


pinkring
prev | next
random | join
For The Dreamers

← Random? β†’