Hide directories that have no content
This commit is contained in:
parent
114a0f29b7
commit
386f323dd0
@ -108,6 +108,10 @@ class Template
|
||||
'class' => ($current_url === $link) ? 'active' : ''
|
||||
];
|
||||
} elseif ($node instanceof Directory) {
|
||||
if (!$node->hasContent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$link = ($path === '') ? $url : $path . '/' . $url;
|
||||
|
||||
$folder = [
|
||||
|
@ -98,6 +98,27 @@ class Directory extends Entry
|
||||
$this->first_page = $first_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when creating the navigation.
|
||||
* Hides folders without showable content
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContent()
|
||||
{
|
||||
foreach ($this->getEntries() as $node) {
|
||||
if ($node instanceof Content) {
|
||||
return true;
|
||||
} elseif ($node instanceof Directory) {
|
||||
if ($node->hasContent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function compareEntries($a, $b)
|
||||
{
|
||||
$name_a = explode('_', $a->name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user