-
Notifications
You must be signed in to change notification settings - Fork 0
Theme helpers
assetassetModuleassetThemebasePathblockscssdoctypeheadLinkheadMetaheadScriptheadTitleI18nThemejQueryjsmetanavigationtemplatetemplateModuletemplateThemeurl
asset -- getting URI of an asset folder of module or theme.
Description
Object asset(string $component, string $file)
Parameters
component
Component including asset file, such as theme/default, module/demo.
file
File name to build asset URI.
Example
echo $this->asset('theme/default', 'css/style.css');
echo $this->asset('module/demo', 'js/demo.js');
Output:
'http://localhost/XoopsEngine/www/asset/theme-default/css/style.css'
'http://localhost/XoopsEngine/www/asset/module-demo/js/demo.js'
assetModule -- building module asset URI.
Description
string assetModule(string $file, string $module = null)
Parameters
file
File name for building module asset URI.
module
Module name.
Example
echo $this->assetModule('css/style.css');
echo $this->assetModule('js/file1.css', 'demo');
Output:
'http://localhost/XoopsEngine/www/asset/module-system/css/style.css'
'http://localhost/XoopsEngine/www/asset/module-demo/js/file1.js'
assetTheme -- building theme asset URI.
Description
string assetTheme(string $file, string $theme = null)
Parameters
file
File name for building theme asset URI.
module
Theme name.
Example
echo $this->assetTheme('css/style.css');
echo $this->assetTheme('image/logo.png', 'dev');
Output:
'http://localhost/XoopsEngine/www/asset/theme-default/css/style.css'
'http://localhost/XoopsEngine/www/asset/theme-dev/image/logo.png'
basePath -- building a base path.
Description
string basePath(string $file)
Parameters
file
File name for building base path.
Example
echo $this->basePath('index.php');
echo $this->basePath('asset');
Output:
'http://localhost/XoopsEngine/www/index.php'
'http://localhost/XoopsEngine/www/asset'
blocks -- loading blocks of a specified zone.
Description
array|Blocks blocks(string $zone)
Parameters
zone
Zone to load blocks. The value can be 0-8, or null.
Example
$blocks = $this->blocks();
$blocks = $this->blocks(1);
if (isset($blocks[1])) {
foreach ($blocks as $key => $block) {
include $this->template('block.phtml');
}
}
css -- loading CSS files.
Description
Object css(string|array $file)
Parameters
file
File name of CSS file or array include file name of CSS files.
Example
$this->css('file.css');
$this->css(array('file1.js', 'file2.js'));
echo $this->headLink();
Output:
'<link href="file.css" media="screen" rel="stylesheet" type="text/css" >'
'<link href="file1.js" media="screen" rel="stylesheet" type="text/css" >'
'<link href="file2.js" media="screen" rel="stylesheet" type="text/css" >'
doctype -- creating a doctype of HTML and XHTML document.
Description
Object doctype(string $doctype)
Parameters
doctype
The doctype allows you to specify one of the following types:
XHTML11
XHTML1_STRICT
XHTML1_TRANSITIONAL
XHTML1_FRAMESET
XHTML1_RDFA
XHTML_BASIC1
HTML4_STRICT
HTML4_LOOSE
HTML4_FRAMESET
HTML5
Example
echo $this->doctype('XHTML1_STRICT');
Output:
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
headLink -- creating and aggregating HTML <link> element for later retrieval and output in your layout script.
Description
Object headLink(array $attributes = null, $placement = Placeholder\Container\AbstractContainer::APPEND)
Parameters
attributes
Attributes to create link.
Example
echo $this->headLink();
echo $this->headLink(array(
'rel' => 'icon',
'href' => '/img/favicon.ico'),
'PREPEND');
Output of second line:
'<link href="/img/favicon.ico" rel="icon" >'
headMeta -- creating HTML <meta> element for later retrieval and output.
Description
Object headMeta(string $content = null, string $keyValue = null, string $keyType = 'name', array $modifiers = array(), string $placement = Placeholder\Container\AbstractContainer::APPEND)
Parameters
content
Content of meta.
keyValue
Content for the key specified in $keyType.
keyType
May be specified as property if the doctype has been set to XHTML1_RDFA.
placement
Can be SET, APPEND or PREPEND.
Example
echo $this->headMeta();
echo $this->headMeta()->appendName('keywords', 'framework, PHP, productivity');
Output of second line:
'<meta name="keywords" content="framework, PHP, productivity" >'
headScript -- creating HTML <script> element for later retrieval and output.
Description
Object headScript(string $mode = HeadScript::FILE, string $spec = null, string $placement = 'APPEND', array $attrs = array(), string $type = 'text/javascript')
Parameters
mode
May be specified as FILE or SCRIPT.
spec
Url of script.
placement
Can be SET, APPEND or PREPEND.
attrs
Attributes of script.
type
Type of script or array of script attributes.
Example
$this->headScript()->appendFile('/js/scriptaculous.js');
headTitle -- creating and storing a HTML <title> element for later retrieval and output programmatically.
Description
Object headTitle(string $title = null, string $setType = null)
Parameters
title
Name of title.
setType
Type of title, the value can be APPEND, PREPEND or SET.
Example
echo $this->headTitle();
echo $this->headTitle('Zend Framework');
Output of second line:
'<title>Zend Framework</title>'
I18nTheme -- loading a theme i18n resource.
Description
Object I18nTheme(string $domain, string $theme = null, string $locale = null)
Parameters
domain
Domain name.
theme
Theme name to use.
locale
Language name to use.
Example
$this->i18nTheme('main');
$this->i18nTheme('main', 'default');
$this->i18nTheme('main', null, 'en');
jQuery -- loading jQuery files or css files, if there is no parameter assigned, it will load jquery.min.js file as default.
Description
void jQuery(string|array $filename)
Parameters
filename
Name of jQuery file want to load.
Example
$this->jQuery();
$this->jQuery('extension.js');
$this->jQuery(array('example.js', 'jQuery.min.js'));
echo $this->headScript();
Output:
<script type="text/javascript" src="http://localhost/XoopsEngine/www/static/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="http://localhost/XoopsEngine/www/static/js/jquery/extension.js"></script>
<script type="text/javascript" src="http://localhost/XoopsEngine/www/static/js/jquery/example.js"></script>
<script type="text/javascript" src="http://localhost/XoopsEngine/www/static/js/jquery/jQuery.min.js"></script>
js -- loading JavaScript files.
Description
Object js(string|array $file)
Parameters
file
File name of JavaScript file or array include file name of CSS files.
Example
$this->js('file.js');
$this->js(array('file1.js', 'file2.js'));
echo $this->headScript();
Output:
'<script type="text/javascript" src="file.js"></script>'
'<script type="text/javascript" src="file1.js"></script>'
'<script type="text/javascript" src="file2.js"></script>'
meta -- getting meta data from application's config table.
Description
string|Meta meta(string $name)
Parameters
name
Field name of meta array.
Example
echo $this->meta('sitename');
echo $this->meta('keywords');
Output as default:
'Xoops Engine'
'Xoops Engine, Web application'
navigation -- used to load a navigation, breadcrumbs navigation or set menu class for XoopsEngine.
Description
Navigation navigation(string $name = null, bool $isGlobal = false)
Parameters
name
Navigation name. In XoopsEngine, it can be set to front or admin to load a front navigation or admin navigation.
isGlobal
Whether to load a global navigation.
Example
// load a front navigation, not global, you can define the navigation by yourselves
$this->navigation('front');
// Render a navigation
$this->navigation('front')->render();
// load a global admin navigation
$this->navigation('admin', true);
// add a breadcrumbs navigation
$this->navigation()->breadcrumbs();
// Render HTML <link> element
$this->navigation()->links();
// set the class for navigation menu
$this->navigation()->menu()->setUIClass(jd_menu);
template -- getting a path of template file if the path is exists.
Description
string template(string $template)
Parameters
template
Template name.
Example
echo $this->template('block.phtml');
Output such as:
'D:/wamp/www/XoopsEngine/usr/theme/default/template/block.phtml'
templateModule -- getting full path of a module template if it exists.
Description
string templateModule(string $template, string $module = null)
Parameters
template
Template name.
module
Module name, if set to null, the current module will be used.
Example
echo $this->templateModule('admin/block-add.phtml', 'system');
echo $this->templateModule('front/login.phtml');
Output such as:
'D:/wamp/www/XoopsEngine/usr/module/system/template/admin/block-add.phtml'
'D:/wamp/www/XoopsEngine/usr/module/login/template/front/login.phtml'
templateTheme -- getting full path of a theme template if it exists.
Description
string templateTheme(string $template)
Parameters
template
Template name.
Example
$this->templateTheme('block.phtml');
Output such as:
'D:/wamp/www/XoopsEngine/usr/theme/default/template/block.phtml'
url -- generating an url by given name and route .
Description
Object url(string $name = null, array $params = array(), array $options = array(), boolean $reuseMatchedParams = false)
Parameters
name
Name of the route, can set to default for front-end, admin for admin-end, home for homepage and feed for feed section.
params
Parameters for generating url.
options
Options for the route.
attrs
Attributes of script.
reuseMatchedParams
Whether to reuse matched parameters.
Example
$this->url('', array(
'module' => 'system',
'controller' => 'index',
'action' => 'index',
));
$this->url('home');
$this->url('default', array(
'controller' => 'index',
'action' => 'index',
));
You can also add your parameters to the second parameter of url helper. These parameters will post by GET method, for example:
$this->url('' array(
'controller' => 'login',
'action' => 'login',
'param' => 'hello',
));
The url will be:
'path/to/www/login/login/param-hello'