From Joomla! Documentation

< API15:JInstallerTemplate

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.


Custom uninstall method

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >


uninstall($name, $clientId)
Parameter Name Default Value Description
$name $path The template name
$clientId $clientId The id of the client


boolean True on success

Defined in



jimport( 'joomla.installer.adapters.template' );

Source Body

function uninstall( $name, $clientId )
        // Initialize variables
        $retval = true;

        // For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in.
        if (!$name) {
                JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Template id is empty, cannot uninstall files'));
                return false;

        // Get the template root path
        $client =& JApplicationHelper::getClientInfo( $clientId );
        if (!$client) {
                JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Invalid application'));
                return false;
        $this->parent->setPath('extension_root', $client->path.DS.'templates'.DS.$name);
        $this->parent->setPath('source', $this->parent->getPath('extension_root'));

        $manifest =& $this->parent->getManifest();
        if (!is_a($manifest, 'JSimpleXML')) {
                // Make sure we delete the folders
                JError::raiseWarning(100, JTEXT::_('Template').' '.JTEXT::_('Uninstall').': '.JTEXT::_('Package manifest file invalid or not found'));
                return false;
        $root =& $manifest->document;

        // Remove files
        $this->parent->removeFiles($root->getElementByPath('media'), $clientId);
        $this->parent->removeFiles($root->getElementByPath('administration/languages'), 1);

        // Delete the template directory
        if (JFolder::exists($this->parent->getPath('extension_root'))) {
                $retval = JFolder::delete($this->parent->getPath('extension_root'));
        } else {
                JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Directory does not exist, cannot remove files'));
                $retval = false;
        return $retval;

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >


Code Examples