-
-
Save AFlorencia/7f6d878217fa09508286f9e2a9f11ee8 to your computer and use it in GitHub Desktop.
Template Snippets for Joomla!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# all php files :: disallow direct access of file | |
# between <?php and ?> | |
defined('_JEXEC') or die; | |
# index.php :: define variable with application | |
# between <?php and ?> | |
$app = JFactory::getApplication(); | |
# index.php :: define variable with document | |
# between <?php and ?> | |
$doc = JFactory::getDocument(); | |
# index.php :: define variable with template path | |
# between <?php and ?> | |
$tpath = $this->baseurl.'/templates/'.$this->template; | |
# index.php :: load cascading style sheet throught API | |
# between <?php and ?> | |
$doc->addStyleSheet($tpath.'/css/template.css'); | |
# index.php :: unset css file from head | |
# between <?php and ?> | |
unset($doc->_styleSheets[$this->baseurl.'/media/zoo/assets/css/reset.css']); | |
# index.php :: add custom css | |
# between <?php and ?> | |
$doc->addStyleDeclaration('body{background-color:red;}'); | |
# index.php :: load javascript file | |
# between <?php and ?> | |
$doc->addScript($tpath.'/js/modernizr.js'); | |
# index.php :: unset javascript file from head | |
# between <?php and ?> | |
unset($doc->_scripts[$this->baseurl.'/media/jui/js/bootstrap.min.js']); | |
# index.php :: quickest way to unset all javascript file from head | |
# between <?php and ?> | |
$doc->_scripts = array(); | |
# index.php :: add custom javascript | |
# between <?php and ?> | |
$doc->addScriptDeclaration('alert(\'Hello Joomla!\')'); | |
# index.php :: quickest way to unset plain javascript from head | |
# between <?php and ?> | |
$doc->_script = array(); | |
# index.php :: add custom tag | |
# between <?php and ?> | |
$doc->addCustomTag('<!-- What a beautiful comment! -->'); | |
# index.php :: load the global joomla header | |
# between <head> and </head> | |
<jdoc:include type="head" /> | |
# index.php :: system messages output incl. prevention message box (div tag) | |
# needs variable $app | |
# between <body> and </body> | |
<?php if (!empty($app->getMessageQueue)) : ?> | |
<jdoc:include type="message" /> | |
<?php endif ?> | |
# index.php :: article and component output | |
# between <body> and </body> | |
<jdoc:include type="component" /> | |
# index.php :: module output of "menu", which have to be mentioned in templateDetails.xml | |
# between <body> and </body> | |
<jdoc:include type="modules" name="menu" style="xhtml" /> | |
# templateDetails.xml :: creation of a new module position called "menu"; | |
# between <positions> and </positions> | |
<position>menu</position> | |
# index.php :: insert debug module; important for developers | |
# before </body> | |
<jdoc:include type="modules" name="debug" /> | |
# index.php :: output of the base url | |
# between <?php and ?> | |
echo $this->baseurl; | |
# index.php :: output of sitename | |
# need variable $app | |
# between <?php and ?> | |
echo $app->getCfg('sitename'); | |
# index.php :: if construct; true, if module is published on position menu | |
# between <?php and ?> | |
if ($this->countModules('menu')) : | |
# index.php :: if construct; true, if http user agent is mobile device | |
# between <?php and ?> | |
if(preg_match('/iphone|ipod|opera mini|blackberry|mobile|iemobile/i', $_SERVER['HTTP_USER_AGENT'])) : | |
# index.php :: extend the if statement from above to execute another statement | |
# between <?php and ?> | |
else : | |
# index.php :: closing the if statement | |
# between <?php and ?> | |
endif; | |
# index.php :: short write if, then, else for echo a class | |
# between <?php and ?> | |
echo ($this->countModules('menu')) ? ('class') : ('no-class'); | |
# index.php :: disappear the generator tag | |
# between <?php and ?> | |
$this->setGenerator(null); | |
# index.php :: get params (line 1) and | |
# get the page class from the current menu entry (line 2) | |
# needs variable $app | |
# between <?php and ?> | |
$params = $app->getParams(); | |
$pageclass = $params->get('pageclass_sfx'); | |
# index.php :: load the modal behavior | |
# between <?php and ?> | |
JHTML::_('behavior.modal'); | |
# index.php :: activate modal window | |
# between <html> and </html> or in articles and modules | |
<a class="modal"></a> | |
# index.php :: insert translatable text | |
# between <?php and ?> | |
echo JText::_('EXAMPLE_TEXT'); | |
# en-GB.tpl_templatename.ini | |
# new row | |
EXAMPLE_TEXT="What a beautiful text." | |
# index.php :: display short system language tag; e.g. en-gb | |
# between <?php and ?> | |
echo $this->language; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment