mirror of
https://github.com/getgrav/grav.git
synced 2026-02-08 07:40:23 +01:00
Add blueprints support for modular content
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user