2017 © Pedro Peláez
 

library view

Anax View module.

image

anax/view

Anax View module.

  • Monday, April 23, 2018
  • by mikael_roos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3,391 Installations
  • PHP
  • 24 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 27 Versions
  • 9 % Grown

The README.md

Anax View

Latest Stable Version Join the chat at https://gitter.im/mosbth/anax, (*1)

Build Status CircleCI, (*2)

Build Status Scrutinizer Code Quality Code Coverage, (*3)

Maintainability Codacy Badge, (*4)

Anax View module to supply a structure of views to a Anax website., (*5)

About views, terminology and structure

The views, also known as template files, are pure PHP files and their purpose is to render content onto a html structure to create a web page., (*6)

It works like this:, (*7)

  1. The content of the webpage is gathered as a collection of views.
  2. The view collection is created in the router callbacks and controllers.
  3. A view is a combination of variables (content), commonly known as $data, which is supplied to a template file, which is executed and renders the data onto a html structure.
  4. Each view is a small part of html and content and rendered onto the web page.

You can see a sample of views in the directory view/anax/v2., (*8)

Views are rendered in a layout

The views are rendered in an orderd fashion by a structured layout. This layout is in itself a view (template file and data), it is just a view which renders more views., (*9)

You can see a sample of an layout view in view/anax/v2/layout., (*10)

The layout views you above have organised each part of the web page as regions. Each view is rendered in a region., (*11)

This code shows how a general region is setup in the layout file, and how it renders the views belonging to this region., (*12)

<!-- flash -->
<?php if (regionHasContent("flash")) : ?>
<div class="outer-wrap outer-wrap-flash">
    <div class="inner-wrap inner-wrap-flash">
        <div class="row">
            <div class="region-flash">
                <?php renderRegion("flash") ?>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>

You can optionally add a region, and a sort value, when you add the views to the collection. This is what decides where (region), and in what order the view is rendered., (*13)

A template file for the view

A template file is an ordinary PHP-file. Here is the template file anax/v2/article/default., (*14)

<article <?= classList($classes) ?>>
= $content ?>
</article>

The namespace makes it possible to access a list of built in view helper functions, for example helper functions to escape output or create urls into the framework or assets., (*15)

namespace Anax\View;

The commented section can be uncommented for debugging what helper functions and what variables that are available., (*16)

// Show incoming variables and view helper functions
//echo showEnvironment(get_defined_vars(), get_defined_functions());

The general idea is then to further prepare content through incoming variables., (*17)

// Prepare classes
$classes[] = "article";
if (isset($class)) {
    $classes[] = $class;
}

Then finally render the output., (*18)

<article <?= classList($classes) ?>>
<?= $content ?>
</article>

That is the general procedures of a template file., (*19)

View helpers

The file View/ViewHelperFunctions holds the helper functions that eases work in the template files., (*20)

Here are some essential helpers., (*21)

Function Details
asset($url) Create a link to a static asset (css, img, php-file, pdf).
e($str) A shortcut for `htmlentities().
url($url) Create an url within the framework, for example "" (home route) or "doc/about".
redirect($url) Redirect to another url (within the framework), for example "game/init".

Review the helper files for details., (*22)

Dumb views or fat views

A view can be "dumb" and only recive input from the framework, and render it with the html code., (*23)

A view can also be "fat", or perhaps not so "smart", and make calls back into the framework., (*24)

The general recomendation is to have dumb views and not make calls back into the framwork., (*25)

Type of views

A view can generally render any type of result and is not limited to html only., (*26)

License

This software carries a MIT license. See LICENSE.txt for details., (*27)

 .  
..:  Copyright (c) 2013 - 2019 Mikael Roos, mos@dbwebb.se

The Versions

23/04 2018

dev-master

9999999-dev https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

23/04 2018

v1.0.26

1.0.26.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

23/04 2018

v1.0.25

1.0.25.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

14/03 2018

v1.0.24

1.0.24.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

17/10 2017

v1.0.23

1.0.23.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

14/09 2017

v1.0.22

1.0.22.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

14/09 2017

v1.0.21

1.0.21.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

12/09 2017

v1.0.20

1.0.20.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

11/09 2017

v1.0.19

1.0.19.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

10/09 2017

v1.0.18

1.0.18.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

07/09 2017

v1.0.17

1.0.17.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

05/09 2017

v1.0.16

1.0.16.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

15/08 2017

v1.0.15

1.0.15.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

14/08 2017

v1.0.14

1.0.14.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

10/08 2017

v1.0.13

1.0.13.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

micro framework boilerplate mvc education

03/08 2017

v1.0.12

1.0.12.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

27/06 2017

v1.0.11

1.0.11.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

26/06 2017

v1.0.10

1.0.10.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

26/06 2017

v1.0.9

1.0.9.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

30/03 2017

v1.0.8

1.0.8.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

27/03 2017

v1.0.7

1.0.7.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

17/03 2017

v1.0.6

1.0.6.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

17/03 2017

v1.0.5

1.0.5.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

10/03 2017

v1.0.3

1.0.3.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

09/03 2017

v1.0.2

1.0.2.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

09/03 2017

v1.0.1

1.0.1.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education

09/03 2017

v1.0.0

1.0.0.0 https://dbwebb.se/anax

Anax View module.

  Sources   Download

MIT

The Requires

 

The Development Requires

  • php >=5.6

micro framework boilerplate mvc education