Add blueprints support for modular content

This commit is contained in:
Matias Griese
2014-10-08 14:21:24 +03:00
parent f9bfed2b22
commit a811ee67cc
3 changed files with 37 additions and 5 deletions

View File

@@ -643,7 +643,7 @@ class Page
$this->template = $var;
}
if (empty($this->template)) {
$this->template = str_replace(CONTENT_EXT, '', $this->name());
$this->template = ($this->modular() ? 'modular/' : '') . str_replace(CONTENT_EXT, '', $this->name());
}
return $this->template;
}

View File

@@ -343,7 +343,19 @@ class Pages
{
$types = self::getTypes();
return $types->toSelect();
return $types->pageSelect();
}
/**
* Get available page types.
*
* @return array
*/
static public function modularTypes()
{
$types = self::getTypes();
return $types->modularSelect();
}
/**

View File

@@ -29,9 +29,8 @@ class Types implements \ArrayAccess, \Iterator, \Countable
'filters' => [
'key' => '|\.yaml$|'
],
'key' => 'Filename',
'key' => 'SubPathName',
'value' => 'PathName',
'recursive' => false
];
$this->items = Folder::all($path, $options) + $this->items;
@@ -52,15 +51,36 @@ class Types implements \ArrayAccess, \Iterator, \Countable
foreach (Folder::all($path, $options) as $type) {
$this->register($type);
}
if (file_exists($path . 'modular/')) {
foreach (Folder::all($path . 'modular/', $options) as $type) {
$this->register($type);
}
}
}
public function toSelect()
public function pageSelect()
{
$list = [];
foreach ($this->items as $name => $file) {
if (strstr($name, '/')) {
continue;
}
$list[$name] = ucfirst(strtr($name, '_', ' '));
}
ksort($list);
return $list;
}
public function modularSelect()
{
$list = [];
foreach ($this->items as $name => $file) {
if (strstr($name, 'modular/') !== 0) {
continue;
}
$list[$name] = trim(ucfirst(strtr($name, '_', ' ')));
}
ksort($list);
return $list;
}
}