- date
- datetime
- number
- currency
- price
- country
- concat
- action
- options
- checkbox
- massaction
- radio
- input
- select
- text
- store
- wrapline
- theme
Add New Parameter in URL
1 2 3 |
$url =& JURI::getInstance(); $url->setVar( 'test', 1); print $url; |
Ignore a file/directory
Git lets you ignore those files by assuming they are unchanged. This is done by running the
1 |
git update-index --assume-unchanged path/to/file.txt |
command. Once marking a file as such, git will completely ignore any changes on that file; they will not show up when running
1 |
git status |
or
1 |
git diff |
, nor will they ever be committed.
To make git track the file again, simply run
git update-index --no-assume-unchanged path/to/file.txt
.
To make a directory ignored:
After cd
ing into the folder you want to assume is unchanged, you can do either this:
1 |
git ls-files | tr '\n' '\0' | xargs -0 git update-index --assume-unchanged |
Access Parent window element from iFrame
1 2 3 |
<script type="text/javascript"> parent.top.jQuery('div#test_div').html('testing parent'); </script> |
Load Language file in Joomla
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<?php $lang = JFactory::getLanguage(); $filename = 'plg_content_vote'; $lang->load($filename, JPATH_ADMINISTRATOR, 'en-GB', true); $lang->load($filename, JPATH_ADMINISTRATOR, $lang->getDefault(), true); Reference: libraries\joomla\language\language.php /** * Loads a single language file and appends the results to the existing strings * * @param string $extension The extension for which a language file should be loaded. * @param string $basePath The basepath to use. * @param string $lang The language to load, default null for the current language. * @param boolean $reload Flag that will force a language to be reloaded if set to true. * @param boolean $default Flag that force the default language to be loaded if the current does not exist. * * @return boolean True if the file has successfully loaded. * * @since 11.1 */ public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false, $default = true) { if (!$lang) { $lang = $this->lang; } $path = self::getLanguagePath($basePath, $lang); $internal = $extension == 'joomla' || $extension == ''; $filename = $internal ? $lang : $lang . '.' . $extension; $filename = "$path/$filename.ini"; $result = false; if (isset($this->paths[$extension][$filename]) && !$reload) { // This file has already been tested for loading. $result = $this->paths[$extension][$filename]; } else { // Load the language file $result = $this->loadLanguage($filename, $extension); // Check whether there was a problem with loading the file if ($result === false && $default) { // No strings, so either file doesn't exist or the file is invalid $oldFilename = $filename; // Check the standard file name $path = self::getLanguagePath($basePath, $this->default); $filename = $internal ? $this->default : $this->default . '.' . $extension; $filename = "$path/$filename.ini"; // If the one we tried is different than the new name, try again if ($oldFilename != $filename) { $result = $this->loadLanguage($filename, $extension, false); } } } return $result; } ?> |
Read XLS/CSV file by PHPExcel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
<?php /** Include PHPExcel_IOFactory */ require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers/PHPExcel/Classes/PHPExcel/IOFactory.php'); // Read XLS file $objPHPExcel = PHPExcel_IOFactory::load($filepath); $rows = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); // Read CSV file $inputFileType = 'CSV'; $inputFileName = $filepath; $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); $worksheet = $objPHPExcel->getActiveSheet(); foreach ($worksheet->getRowIterator() as $row) { echo 'Row number: ' . $row->getRowIndex() . "\r\n"; $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set foreach ($cellIterator as $cell) { if (!is_null($cell)) { echo 'Cell: ' . $cell->getCoordinate() . ' - ' . $cell->getValue() . "\r\n"; } } } OR $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); //read from file $rows = array(); for ($row = 1; $row <= $highestRow; ++$row) { $file_data = array(); for ($col = 0; $col < $highestColumnIndex; ++$col) { $value=$objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); $file_data[$col]=trim($value); } $rows[] = $file_data; } ?> |
Load Joomla module
1 2 3 4 5 6 |
<?php $module = JModuleHelper::getModule('mod_glocator_search'); $attribs = array('layout' => 'search1'); $html = JModuleHelper::renderModule($module, $attribs); echo $html; ?> |
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); ?> |