mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 03:21:33 +01:00
Set template type based on request headers content-type if set
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
1. [](#improved)
|
||||
* Allow custom Flex form views
|
||||
* Cleaned up and sorted the Service `idMap`
|
||||
* Allow request headers `Content-Type` to set the template type [form#221](https://github.com/getgrav/grav-plugin-form/issues/221)
|
||||
|
||||
# v1.6.0-beta.5
|
||||
## 11/05/2018
|
||||
|
||||
@@ -1288,7 +1288,10 @@ class Page implements PageInterface
|
||||
}
|
||||
|
||||
if (empty($this->template_format)) {
|
||||
$this->template_format = Grav::instance()['uri']->extension('html');
|
||||
$content_type = Grav::instance()['uri']->getContentType(true);
|
||||
$fallback_type = Utils::getExtensionByMime($content_type);
|
||||
$default = is_null($content_type) ? Grav::instance()['uri']->extension('html') : $fallback_type;
|
||||
$this->template_format = $default;
|
||||
}
|
||||
|
||||
return $this->template_format;
|
||||
|
||||
@@ -1307,7 +1307,7 @@ class Uri
|
||||
* @param bool $short
|
||||
* @return null|string
|
||||
*/
|
||||
private function getContentType($short = true)
|
||||
public function getContentType($short = true)
|
||||
{
|
||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||
$content_type = $_SERVER['CONTENT_TYPE'];
|
||||
|
||||
Reference in New Issue
Block a user