Last active
October 27, 2018 18:04
-
-
Save dongilbert/6089087 to your computer and use it in GitHub Desktop.
Joomla getName() method to strip format from returned view name.
This file contains hidden or 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
<?php | |
class JModelLegacy | |
{ | |
/** | |
* Method to get the view name | |
* | |
* The view name by default parsed using the classname, or it can be set | |
* by passing a $config['name'] in the class constructor | |
* | |
* @return string The name of the view | |
* | |
* @since 11.1 | |
*/ | |
public function getName() | |
{ | |
if (empty($this->_name)) | |
{ | |
$class = get_class($this); | |
$pos = strpos($class, 'View'); | |
if ($pos === false) | |
{ | |
JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME')); | |
} | |
$tmp = strtolower(substr($class, ($pos + 4))); | |
// Remove the format from the end of the string. | |
$format = JFactory::getApplication()->input->get('format', 'html'); | |
$this->_name = preg_replace('/(' . strtolower($format) . ')$/', '', $tmp); | |
} | |
return $this->_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to apply this to Joomla 2.5?