mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 19:41:36 +01:00
Little cleanup
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
## xx/xx/2017
|
||||
|
||||
1. [](#improved)
|
||||
* Added various `ancestor` helper methods in Page and Pages classes [#1362](https://github.com/getgrav/grav/pull/1362)
|
||||
* Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400)
|
||||
* Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377)
|
||||
* Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393)
|
||||
|
||||
@@ -303,7 +303,7 @@ class Pages
|
||||
{
|
||||
if (!is_null($path)) {
|
||||
|
||||
$page = $this->getPage($route);
|
||||
$page = $this->dispatch($route, true);
|
||||
|
||||
if ($page->path() == $path) {
|
||||
return $page;
|
||||
@@ -327,7 +327,7 @@ class Pages
|
||||
{
|
||||
if (!is_null($field)) {
|
||||
|
||||
$page = $this->getPage($route);
|
||||
$page = $this->dispatch($route, true);
|
||||
|
||||
$ancestorField = $page->parent()->value('header.' . $field);
|
||||
|
||||
@@ -366,7 +366,12 @@ class Pages
|
||||
*/
|
||||
public function dispatch($route, $all = false, $redirect = true)
|
||||
{
|
||||
$page = $this->getPage($route);
|
||||
// Fetch page if there's a defined route to it.
|
||||
$page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null;
|
||||
// Try without trailing slash
|
||||
if (!$page && Utils::endsWith($route, '/')) {
|
||||
$page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null;
|
||||
}
|
||||
|
||||
// Are we in the admin? this is important!
|
||||
$not_admin = !isset($this->grav['admin']);
|
||||
@@ -434,22 +439,6 @@ class Pages
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve page instance based on the route
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
protected function getPage($route) {
|
||||
// Fetch page if there's a defined route to it.
|
||||
$page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null;
|
||||
// Try without trailing slash
|
||||
if (!$page && Utils::endsWith($route, '/')) {
|
||||
$page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null;
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get root page.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user