Closed estudiooka closed 10 years ago
First thanks for your pull request. But I can't see the benefit, please can you explain why you need this change? Maybe give us some examples.
I can see this being useful for loading a bunch of markdown files from a plugins folder.
+1 ok, nice idea, now I understand the benefit.
Sometimes I need a collection of .md, but I don't want then on my pages. So I made a quick plugin for collections using the page repository.
index.php define('CONTENT_DIR', ROOT_DIR . 'content/pages' . DIRECTORY_SEPARATOR);
plugin.php
public function on($eventKey, $data = null) {
if ($eventKey == 'template_engine_registered') {
$collection = new Twig_SimpleFunction('collection', function ($folder) {
return $this->getCollections($folder);
});
$data['engine']->addFunction($collection);
}
}
private function getCollections($folder) {
$this->pageRepository = new \Phile\Repository\Page();
$collection = $this->pageRepository->findAll( NULL, ROOT_DIR. 'content/collections/'.$folder) ;
return $collection;
}
@NeoBlack is this ok to merge? I like it.
Make page model more flexible adding $folder = CONTENT_DIR so it’s possible to select where start the page tree, useful for creating plugins.