R3m/framework Add web assets

We need to set the environment to development if not done already.

<name> configure environment toggle

<name> the binary name of R3m/framework (see installation).
It says Production mode enabled. or Development mode enabled..
We need Development mode enabled..

We change our view file: <project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/View/Get.tpl.

 *  Where menu.get() shows
 *  <ul class="menu">
 *      <a href="{/page/Welcome/" class="page-welcome"><li>...</li></a>
 *      ...
 *  </ul> 

 *  Where page.get() shows
 *  Hello world, this is page Welcome
{$page = page.get()}
 *  $controller.dir.view = <project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/View/

Where <project_dir>Host/<subdomain>/<hostname>/<extension>/Docs/View/Link/Get.tpl is the template to require().

    <link rel="stylesheet" href="{$host.url|default:'/'}Docs/Css/Get.css?{$version|default:'0.0.1'}">    

This stylesheet is appended to the variable $link which is an array [] and used in Main.tpl.

{$read = parse.read(config('controller.dir.data') + 'Main.json')}<!DOCTYPE html>
        {if (!is.empty($script) && is.array($script))}
            {implode("\n\t\t\t", $script)}
        {if (!is.empty($link) && is.array($link))}            
            {implode("\n\t\t\t", $link)}

To add an image:

Edit the Get.tpl.


With content:

<img src="{$host.url}Docs/Image/Logo.png" class="logo" />
{$page = request('page')}
Hello world, this is page {$page|lowercase} 

If you reload the page and go to the network tab (F12) resource Logo.png:

array(5) {
[0]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/View/Public/Image/Logo.png",
[1]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/Public/Image/Logo.png",
[2]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Docs/Image/Public/Logo.png",
[3]=> "<project_dir>/Host/<subdomain>/<hostname>/<extension>/Public/Docs/Image/Logo.png",
[4]=> "<project_dir>/Public/Docs/Image/Logo.png"

Place the logo in one of these 5 locations.

Last modified: 2021-06-07

© 2021 universeorange.com