“Cannot delete last style of a template” When Uninstalling a Joomla Template

Here’s a small Saturday niblet… While trying to uninstall a template from the Template Manager, we encountered the following error:

Cannot delete last style of a template

And, of course, we were not able to uninstall the template. Uninstalling the template was necessary for us because we wanted to re-install it as it had an error.

But, on the bright side, we knew another way for uninstalling templates (well, we knew many ways, but that was the easiest one). All that we needed to do was to go Extensions -> Extensions Manager, and then click on Manage on the secondary menu, and then search for the name of the template (e.g. type in the name of the template in the Filter box), and then click on the checkbox next to it, and finally click on Uninstall on the top right. (We know, too many “and thens”, even more “and thens” than that scene in Dude, Where’s my car). And Guess what, that worked!

But what causes this problem?

Well, it’s because Joomla doesn’t allow you, through the Template Manager, to delete all the styles of a specific template. For example, if a template has 5 styles, then you are only allowed to delete 4 through the template manager. The last one cannot be deleted from there. This behavior is controlled by the function delete in the file style.php which is located under the administrator/components/com_templates/tables/style.php. To be more specific, in the following code (lines 110-113 of the aforementioned file):

if (count($results)==1 && $results[0]==$pk) {
	$this->setError(JText::_('COM_TEMPLATES_ERROR_CANNOT_DELETE_LAST_STYLE'));
	return false;
}

Now, if you’re seeing the same error when uninstalling a template, then try to uninstall it from the Extensions Manager instead of doing it from the Template Manager. If that also fails, then why not contact us? We can definitely help! Our work is fast, our quality is top notch, and we don’t charge much.

One Response to ““Cannot delete last style of a template” When Uninstalling a Joomla Template”
  1. Pingback by “The template for this display is not available.” Error on Joomla | itoctopus — October 2, 2013 @ 4:53 am

    […] it was! We even uninstalled and reinstalled the template (note: when we deleted the template we saw this error). Double […]

Leave a comment