Frequently used tasks
Generate internal link
All links on the page should be generated through global variable $site.
<?php
global $site;
//public function generateUrl($languageId=null, $zoneName = null, $urlVars = null, $getVars = null);
$site->generateUrl(); //link to main page of current language
$site->generateUrl($languageId); //link to main page of specified language
$site->generateUrl(null, 'zoneName'); //link to first page of specified zone
$site->generateUrl(null, null, array('url1', 'url2'), array('get1'=>'val1', 'get2'=>'val2')) //link to current language current zone with following suffix: /url1/url2/?get1=val1&get2=val2
?>
Get variable / option / translation from configuration
Use global variable $parametersMod to get modules configuration values or translations.
You can preview all configuration values and create new ones through Developer -> Modules config.
Common values are also accessible in Standard -> Configuration.
Don't type any text directly on theme (template).
Create required texts in configuration and include them with $parametersMod->getValue('moduleGroupName', 'moduleName', 'parametersGroupName', 'parameterName') method.
<?php
global $parametersMod;
echo $parametersMod->getValue('standard', 'configuration', 'translations', 'copyright'); //will output copyright notice.
?>
Get meta tags information
<?php global $site; $site->getTitle() //get current page title $site->getKeywords() //get current page keywords $site->getDescription() //get current page description ?>
Generate link to your image or CSS file in theme
<?php BASE_URL.THEME_DIR.THEME.'/your.css'; //link to css file in your theme BASE_URL.THEME_DIR.THEME.'/images/logo.jpg'; //link to image in your theme ?>
Generate menu
<?php
require_once(LIBRARY_DIR.'php/menu/common.php'); //include menu generation class
$menuTop = new Library\Php\Menu\Common(); //create object
echo $menuTop->generate('top'); //generates menu list. Replace top to any other zone name
echo $menuTop->generate('top', $startDepth, $depthLimit); //you can limit menu depth. If $startDepht and $depthLimit are 2 and 3 respectively, then function will output tree levels of menu starting from second level.
?>
Generate language selection box
<?php require_once (BASE_DIR.MODULE_DIR.'standard/languages/module.php'); echo \Modules\standard\languages\Module::generateLanguageList(); ?>
Generate breadcrumb
<?php require_once(MODULE_DIR.'standard/breadcrumb/module.php'); echo \Modules\standard\breadcrumb\Module::generateBreadcrumb(); //genearates breadcrumb with links echo \Modules\standard\breadcrumb\Module::generateBreadcrumb($separator); //$separator - html code to separate elements. ?>
Generate page content
<?php php echo $site->generateContent(); ?>
Write a comment
You must be logged in to comment.