1

In my Joomla component I have a bunch of Javascript files in media that change on update ( basically a compiled Angular app ) and because of the way the system is structured, I need to only have the current files in the folder. However when I install my component as an update, it leaves the old files in the media/com_mycomponent folder.

What is the best way to clear out the old files during installation?

1 Answer 1

3

Create a installer script for your component (com_your_component_name/script.php) and add the following code:

<?php
defined('_JEXEC') or die;

class com_your_component_nameInstallerScript
{
  function update($parent) 
  {
    JFile::delete($path.$file)
  } 
}

The installer script file allows you to run code when your component is installed, uninstalled, or updated, and also before and after the component is installed.

https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_an_install-uninstall-update_script_file

https://docs.joomla.org/How_to_use_the_filesystem_package

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.