Views

The framework is mvc based, which stands for model, view, controller. The mvc design pattern is build with this structure where, models are used for database interaction, views for the html markup and controllers for the main/core logic of the webapplication. Commonly, controllers return views and model instances are created inside controllers.

Creating a view

Views can be created inside the /app/views folder.

<!DOCTYPE html>
<html lang="en">             
  <head>
    <title></title>                     
  </head>       
  <body>
  
    <p>Hello world!</p>
              
  </body>               
</html>  

View templating

View templating is a way of organizing views. These templates are just regular views but can be used as templates in other views. View templates should be created inside app/view/includes folder.

Class: Controller (base controller)

In this table you'll find information about the different methods you can use and what kind of data can be passed as an argument.

Method Arg Type Expect
include() 1 string view template
stylesheet() 1 string css href
script() 1 string script src
script() 2 string defer
title() 1 string meta title
description() 1 string meta description
meta() 1 string meta name
meta() 2 string meta content

Creating a view template

Create a view inside the app/views/includes folder and add some html markup.

<footer></footer>               

Including a view template

Call the include function method to include a view template. The argument should be the name of the template without the php extension.

<!DOCTYPE html>
<html lang="en">             
  <head>
    <title>Title</title>                     
  </head>       
  <body>
              
    <?php $this->include('footer'); ?>

  </body>               
</html>          

Linking a css file

Call the stylesheet function method to link a css file. The argument should be the path of the css file + filename. Css files should be created inside the public/assets/css folder.

<!DOCTYPE html>            
<html lang="en">            
  <head>            
    
    <?php $this->stylesheet('/assets/css/style.css'); ?>                 
  
  </head>            
  <body>               

  </body>             
</html>              

Linking a script file

Call the script function method to include the script file. The argument should be the path of the script file + filename. Script files should be created inside the public/assets/js folder.

<!DOCTYPE html>            
<html lang="en">            
  <head>            
    
    <?php $this->script('/assets/js/script.js'); ?>                 
  
  </head>            
  <body>               

  </body>             
</html>              

Adding a meta title

Call the title function method to add a meta title.

<!DOCTYPE html>            
<html lang="en">            
  <head>            
    
    <?php $this->title('Title'); ?>                 
  
  </head>            
  <body>               

  </body>             
</html>              

Adding a meta description

Call the description function method to add a meta description.

<!DOCTYPE html>            
<html lang="en">            
  <head>            
    
    <?php $this->description('Description'); ?>                 
  
  </head>            
  <body>               

  </body>             
</html>              

Adding meta data

Call the meta function method to add meta data.

<!DOCTYPE html>            
<html lang="en">            
  <head>            
    
    <?php $this->meta("viewport", "width=device-width, initial-scale=1"); ?>                 
  
  </head>            
  <body>               

  </body>             
</html>