mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 12:37:51 +02:00
Added support for external_url: page header
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
36
system/blueprints/pages/external.yaml
Normal file
36
system/blueprints/pages/external.yaml
Normal 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
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user