mirror of
https://github.com/getgrav/grav.git
synced 2026-07-06 04:39:09 +02:00
Merge pull request #737 from getgrav/feature/add-base-including-language-to-uri
Add URI::baseIncludingLanguage()
This commit is contained in:
@@ -601,6 +601,27 @@ class Uri
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base relative URL including the language prefix
|
||||
* or the base relative url if multilanguage is not enabled
|
||||
*
|
||||
* @return String The base of the URI
|
||||
*/
|
||||
public function baseIncludingLanguage()
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
// Link processing should prepend language
|
||||
$language = $grav['language'];
|
||||
$language_append = '';
|
||||
if ($language->enabled()) {
|
||||
$language_append = $language->getLanguageURLPrefix();
|
||||
}
|
||||
|
||||
$base = $grav['base_url_relative'];
|
||||
return rtrim($base . $grav['pages']->base(), '/') . $language_append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return root URL to the site.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user