Added support for external_url: page header

This commit is contained in:
Andy Miller
2016-08-17 14:19:20 -06:00
parent 39745be4e8
commit 77a7e3da2e
4 changed files with 48 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
1. [](#improved)
* Important vendor updates to provide PHP 7.1 beta support!
* Added a `Util::arrayFlatten()` static function
* Added support for 'external_url' page header to enable easier external URL based menu items
1. [](#bugfix)
* Fix for lightbox media function throwing error [#981](https://github.com/getgrav/grav/issues/981)

View File

@@ -0,0 +1,36 @@
rules:
slug:
pattern: "[a-zа-я][a-zа-я0-9_\-]+"
min: 2
max: 80
form:
validation: loose
fields:
tabs:
type: tabs
active: 1
fields:
content:
type: tab
title: PLUGIN_ADMIN.CONTENT
fields:
header.title:
type: text
autofocus: true
label: PLUGIN_ADMIN.TITLE
header.external_url:
type: text
label: PLUGIN_ADMIN.EXTERNAL_URL
placeholder: https://getgrav.org
validate:
required: true
options:
type: tab
title: PLUGIN_ADMIN.OPTIONS

View File

@@ -54,6 +54,7 @@ class Page
protected $routable;
protected $modified;
protected $redirect;
protected $external_url;
protected $items;
protected $header;
protected $frontmatter;
@@ -364,6 +365,9 @@ class Page
if (isset($this->header->redirect)) {
$this->redirect = trim($this->header->redirect);
}
if (isset($this->header->external_url)) {
$this->external_url = trim($this->header->external_url);
}
if (isset($this->header->order_dir)) {
$this->order_dir = trim($this->header->order_dir);
}
@@ -1470,6 +1474,11 @@ class Page
/** @var Uri $uri */
$uri = $grav['uri'];
// Override any URL when external_url is set
if (isset($this->external_url)) {
return $this->external_url;
}
// get pre-route
if ($include_lang && $language->enabled()) {
$pre_route = $language->getLanguageURLPrefix();

View File

@@ -52,6 +52,8 @@ class Types implements \ArrayAccess, \Iterator, \Countable
// Register default by default.
$this->register('default');
$this->register('external');
}
foreach ($this->findBlueprints($uri) as $type => $blueprint) {