1 2 3 4 5 6 |
<?php $module = JModuleHelper::getModule('mod_glocator_search'); $attribs = array('layout' => 'search1'); $html = JModuleHelper::renderModule($module, $attribs); echo $html; ?> |
Category / PHP
Unset Mootools from Joomla Head
1 2 3 4 |
<?php $document = JFactory::getDocument(); unset($document->_scripts[JURI::root(true) . '/media/system/js/mootools.js']); ?> |
Php function to make string URL safe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php /** * This method processes a string and replaces all accented UTF-8 characters by unaccented * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercase. */ function stringURLSafe($string) { // Remove any '-' from the string since they will be used as concatenaters $str = str_replace('-', ' ', $string); // Trim white spaces at beginning and end of alias and make lowercase $str = trim(strtolower($str)); // Remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str); // Trim dashes at beginning and end of alias $str = trim($str, '-'); return $str; } ?> |
Joomla Current Time based on Timezone setup at Admin Settings
1 2 3 4 5 6 |
<?php $config = JFactory::getConfig(); $siteOffset = $config->getValue('config.offset'); $dtnow = JFactory::getDate('now', $siteOffset); $now = $dtnow->toMySQL(true); ?> |
Calculate Date difference in PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php // This works only in php 5.3, not work on 5.2 $date_obj1 = new DateTime($date1); $date_obj2 = new DateTime($date2); $interval = $date_obj1->diff($date_obj2); //print_r($interval); //echo “difference ” . $interval->y . ” years, ” . $interval->m.” months, “.$interval->d.” days “.$interval->h.” hrs “.$interval->i.” mins <br>”; // This works in all $date_obj1 = new DateTime($date1); $date_obj2 = new DateTime($date2); $hrs = round(($date_obj2->format(‘U’) – $date_obj1->format(‘U’)) / (60*60)); ?> |