BackendPro User Guide Version 0.6.1


Site Library

The site library replaces the old deprecated Page class. It has the same features as the old Page class apart from it contains no asset related code. This can be found in the new Asset Library.

Important:  This class is initialized automatically by the system so there is no need to do it manually.

Features:

How to use the Site Library?

The site library is loaded by default by the BackendPro Class. The class file can be found at modules/site/libraries/bep_site.php

To access a method in the Site library please using the following syntax:

$this->bep_site->{method_name};

Configuration Settings

All configuration settings for the Site library can be found in modules/site/config/bep_site.php.

Preference Default Value Options Description
default_site_variables Array None Default PHP values to convert to JS variables

Methods

$this->bep_site->set_metatag()

Set a metatag to be created and stored until the page is outputted.

$this->bep_site->set_metatag('tag name','tag content');

// Produces : <meta name='tag name' content='tag content'/>
$this->bep_site->set_metatag('tag name','tag content',true);

// Produces : <meta http-equiv='tag name' content='tag content'/>

$this->bep_site->get_metatags();

Get an HTML string containing all metatags currently added.

$this->bep_site->set_crumb()

Set a new crumb in the breadcrumb trail.

$this->bep_site->set_crumb('name','uri string');

$this->bep_site->get_breadcrumb()

Gets the full breadcrumb trail created up till this point.

$this->bep_site->get_breadcrumb();

So an example of the full use of the breadcrumb trail code is below:

$this->bep_site->set_crumb('BackendPro','');
$this->bep_site->set_crumb('Control Panel','admin');
$this->bep_site->set_crumb('Members','admin/members');

print $this->bep_site->get_breadcrumb();

// Produces:
// <a href="http://localhost/index.php">BackendPro</a> > <a href="http://localhost/index.php/admin">Control Panel</a> > Members

$this->bep_site->set_variable()

Allows a PHP variable to be converted into a JS variable.

$this->bep_site->set_variable('name',value);

It can also handle arrays nested inside arrays or bools in arrays. Most combinations can be converted to there equivalent JS version. If a value type cannot be determined then a JS null value will be used.

$this->bep_site->get_variables()

Gets an HTML string containing the JS code with the converted variables values.

$this->bep_site->get_variables();

$this->bep_site->set_js_block()

Set a JS code block so it can be included in the page header upon output.

$this->bep_site->set_js_block('JS code');

This can be very useful if you need to create some dynamic JS on the fly and can't store it in a asset file. Please note the code block will not be cached and you will still need to load any assets it may use.

$this->bep_site->get_js_blocks()

Get an HTML string containing all JS code blocks inside a <script> tag.

$this->bep_site->get_js_blocks();