From 5bb1c325ff1229f0114dca3796a214c61bebbfc4 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 6 Mar 2016 00:54:36 +0100 Subject: [PATCH] Add onSinglePageLoading event; allow skipping pages in onSinglePageLoaded --- lib/Pico.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 1f4d0eb..5ab4e7f 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1017,6 +1017,9 @@ class Pico $id = substr($file, $contentDirLength, -$contentExtLength); + // trigger onSinglePageLoading event + $this->triggerEvent('onSinglePageLoading', array(&$id)); + // drop inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists) $conflictFile = $contentDir . $id . '/index' . $contentExt; if (in_array($conflictFile, $files, true)) { @@ -1061,10 +1064,12 @@ class Pico unset($rawContent, $meta); - // trigger event + // trigger onSinglePageLoaded event $this->triggerEvent('onSinglePageLoaded', array(&$page)); - $this->pages[$id] = $page; + if ($page !== null) { + $this->pages[$id] = $page; + } } }