Skip to content

Commit

Permalink
Use onGetPageTemplates-event in Admin
Browse files Browse the repository at this point in the history
  • Loading branch information
OleVik committed May 9, 2020
1 parent c59214b commit b9d141a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.0.4
## 09-05-2020

1. [](#bugfix)
* Use onGetPageTemplates-event in Admin
* README-link

# v1.0.3
## 20-02-2020

Expand Down
4 changes: 2 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Scholar
version: 1.0.3
version: 1.0.4
description: An academic-focused theme, for publishing papers, articles, books, documentation, your blog, and even your resumé. Features include high accessibility, fast performance, print-friendly styles and more.
icon: book
author:
Expand All @@ -9,7 +9,7 @@ homepage: https://github.com/OleVik/grav-theme-scholar
demo: https://olevik.me/staging/grav-skeleton-scholar
keywords: grav, theme, academic, paper, papers, article, articles, book, books, docs, documentation, resume, cv
bugs: https://github.com/OleVik/grav-theme-scholar/issues
readme: https://github.com/OleVik/grav-theme-scholar/blob/develop/README.md
readme: https://github.com/OleVik/grav-theme-scholar/blob/master/README.md
license: MIT
dependencies:
- { name: grav, version: "~1.6.21" }
Expand Down
26 changes: 24 additions & 2 deletions scholar.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function onThemeInitialized()
if ($this->isAdmin() && $this->config->get('plugins.admin')) {
$this->enable(
[
'onGetPageBlueprints' => ['onGetPageBlueprints', 0]
'onGetPageBlueprints' => ['onGetPageBlueprints', 0],
'onGetPageTemplates' => ['onGetPageTemplates', 0]
]
);
}
Expand Down Expand Up @@ -226,7 +227,7 @@ public function onGetPageBlueprints(Event $event)
);
if ($componentFolder) {
$folder = $this->grav['locator']->findResource(
$componentFolder,
'theme://components/' . $component,
true,
true
);
Expand All @@ -237,6 +238,27 @@ public function onGetPageBlueprints(Event $event)
}
}

/**
* Register Page blueprints
*
* @param Event $event Instance of RocketTheme\Toolbox\Event\Event.
*
* @return void
*/
public function onGetPageTemplates(Event $event)
{
foreach ($this->config->get('themes.scholar.components') as $component) {
$folder = $this->grav['locator']->findResource(
'theme://components/' . $component,
true,
true
);
if (is_dir($folder)) {
$event->types->scanTemplates($folder);
}
}
}

/**
* Handle API
*
Expand Down

0 comments on commit b9d141a

Please sign in to comment.