Universeorange.com/Docs/
On the controller page we check App::CONTENT_TYPE
.
If this is a html
response then the Main.tpl
is embedded.
With Get
as template.name
which get loaded in Main.tpl
.
If the response is other than html
i.e. json
then Get.tpl
gets loaded.
First the Get.tpl
:
Add a view in:
/
<project_dir>
/Host/<subdomain>
/<hostname>
/<extension>
/Docs/View/Get.tpl
With content:
{$page = request('page')}
Hello world, this is page {$page|lowercase}
And add a view in:
/
<project_dir>
/Host/<subdomain>
/<hostname>
/<extension>
/Docs/View/Main.tpl
In one of these locations:
array(6) {
[0]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/Controller/View/Main.tpl",
[1]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/View/Main.tpl",
[2]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/View/Main.tpl",
[3]=> "<project_dir>/Host/<subdomain>/<hostname>/View/Main.tpl",
[4]=> "<project_dir>/Host/View/Main.tpl",
[5]=> "<project_dir>/View/Main.tpl"
}
{$read = parse.read($r3m.io.config.controller.dir.data + 'Main.json')}
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="{$html.head.author|default:''}"/>
<meta http-equiv="content-type" content="{$html.head.content.type | default:'text/html; charset=UTF-8'}" />
<meta http-equiv="X-UA-Compatible" content="{$html.head.compatible|default:'IE=edge,chrome=1'}">
<meta name="viewport" content="{$html.head.viewport|default:'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'}">
<title>{$html.head.title|default:''}</title>
<meta name="revisit-after" content="{$html.head.revisit|default:'7 days'}" />
<meta name="rating" content="{$html.head.rating|default:'general'}" />
<meta name="distribution" content="{$html.head.distribution|default:'global'}" />
<meta name="keywords" content="{$html.head.keywords}">
<meta name="description" content="{$html.head.description|default:''}">
<link rel="shortcut icon" href="{$html.head.icon|default:''}" />
<link rel="alternate" hreflang="x-default" href="{$url}">
<link rel="canonical" href="{$url}">
{if (!is.empty($script) && is.array($script))}
{implode("\n\t\t\t", $script)}
{/if}
{if (!is.empty($link) && is.array($link))}
{implode("\n\t\t\t", $link)}
{/if}
</head>
<body>
{$html.content.body|default:""}
</body>
</html>
Where <project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/Data/Main.json
is:
{
"url" : "{$host.url}",
"version" : "0.0.1-alpha",
"script" : [
"<script src=\"{$host.url}Js/Priya-0.3.11/Priya/Priya.js\"></script>"
],
"link" : [
"<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\">",
"<link href=\"https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400;1,600&display=swap\" rel=\"stylesheet\">"
],
"meta" : {
"author" : "Remco van der Velde remco@universeorange.com",
"title" : "...",
"description" : "...",
"keywords" : "..."
},
"html" : {
"content" : {
"body" : "{view($template)}"
},
"head" : {
"author" : "{$meta.author}",
"title" : "{$meta.title}",
"description" : "{$meta.description}",
"keywords" : "{$meta.keywords}"
}
}
}
Route
http://<subdomain>.<hostname>.<extension>/Docs/Welcome
should give us:
Hello world, this is page welcome
Next: using plugins
Last modified: 2021-06-07
© 2021 universeorange.com