Location: PHPKode > projects > BackendPro > user_guide/libraries/site.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<title>BackendPro User Guide : Site Library</title>

<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='robots' content='all' /> 



<div id="nav"><div id="nav_inner"></div></div>
<div id="nav2"><a name="top">&nbsp;</a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<td><h1>BackendPro User Guide Version 0.6.1</h1></td>
<td id="breadcrumb_right"><a href="../contents.html">Table of Contents</a></td>

<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<td id="breadcrumb">
<a href="http://www.kaydoo.co.uk/projects/backendpro">BackendPro Home</a> &nbsp;&#8250;&nbsp;
<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;    
Site Library
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="http://www.kaydoo.co.uk/backendpro/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>


<br clear="all" />

<div id="content">

<h1>Site Library</h1>
<p>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 <a href="assets.html">Asset Library</a>.</p>
<p class="important"><strong>Important:</strong>&nbsp; This class is initialized automatically by the system so there is no need to do it manually.</p
    <li><a href="#set_crumb">Breadcrumb trail creation</a></li>
    <li><a href="#set_variable">PHP to JS variable conversion</a></li>
    <li><a href="#set_metatag">Meta tag creation</a></li>
	<li><a href="#set_js_block">Javascript code blocks</a></li>

<h2>How to use the Site Library?</h2>
<p>The site library is loaded by default by the BackendPro Class. The class file can be found at <var>modules/site/libraries/bep_site.php</var></p>

<p>To access a method in the Site library please using the following syntax:</p>

<h2>Configuration Settings</h2>
<p>All configuration settings for the Site library can be found in <var>modules/site/config/bep_site.php</var>.</p>

<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
    <td class="td"><strong>default_site_variables</strong></td>
    <td class="td">Array</td>
    <td class="td">None</td>
    <td class="td">Default PHP values to convert to JS variables</td>


<a name="set_metatag"></a>
<p>Set a metatag to be created and stored until the page is outputted.</p>
	$this-&gt;bep_site-&gt;set_metatag('<var>tag name</var>','<var>tag content</var>');<br/>
	// Produces : &lt;meta name='tag name' content='tag content'/&gt;
	<li>The first parameter is the name of the meta tag you want to create.</li>
	<li>The second parameter is the content you want to store in the metatag.</li>
	<li>The third <strong>optional</strong> parameter sets whether a http-equiv metatag should be created.</li>
	$this-&gt;bep_site-&gt;set_metatag('tag name','tag content',<kbd>true</kbd>);<br/>
	// Produces : &lt;meta http-equiv='tag name' content='tag content'/&gt;

<a name="get_metatags"></a>
<p>Get an HTML string containing all metatags currently added.</p>

<a name="set_crumb"></a>
<p>Set a new crumb in the breadcrumb trail.</p>
	$this-&gt;bep_site-&gt;set_crumb('<var>name</var>','<var>uri string</var>');
	<li>The first parameter is the name of the crumb link you want to display.</li>
	<li>The second <strong>optional</strong> parameter is a CodeIgniter URI string for the link. This should be in the form used by
	the rest of CodeIgniter, i.e. <dfn>controller/method</dfn>.</li>

<a name="get_breadcrumb"></a>
<p>Gets the full breadcrumb trail created up till this point.</p>
<p>So an example of the full use of the breadcrumb trail code is below:</p>
	$this-&gt;bep_site-&gt;set_crumb('Control Panel','admin');<br/>
	print $this-&gt;bep_site-&gt;get_breadcrumb();<br/>
	// Produces:<br/>
	// &lt;a href="http://localhost/index.php"&gt;BackendPro&lt;/a&gt; &gt; &lt;a href="http://localhost/index.php/admin"&gt;Control Panel&lt;/a&gt; &gt; Members<br/>

<a name="set_variable"></a>
<p>Allows a PHP variable to be converted into a JS variable.</p>
	<li>The first parameter is the name you want to the JS variable to have.</li>
	<li>The second parameter is the value you want to assigned to the variable, any of the following PHP variables types can be converted:
			<li>Array (Only arrays with numeric keys)</li>
<p>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 <dfn>null</dfn> value will be used.</p>

<a name="get_variables"></a>
<p>Gets an HTML string containing the JS code with the converted variables values.</p>

<a name="set_js_block"></a>
<p>Set a JS code block so it can be included in the page header upon output.</p>
	$this-&gt;bep_site-&gt;set_js_block('<var>JS code</var>');
<p>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.</p>

<a name="get_js_blocks"></a>
<p>Get an HTML string containing all JS code blocks inside a &ltscript&gt; tag.</p>
<!-- END CONTENT -->

<div id="footer">
<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="../index.html">User Guide Home</a>
<p><a href="http://www.kaydoo.co.uk/projects/backendpro">BackendPro</a> &nbsp;&middot;&nbsp; Copyright &#169; 2009 &nbsp;&middot;&nbsp; <a href="http://www.kaydoo.co.uk">Adam Price</a></p>


Return current item: BackendPro