I've a module that I want to run a script post installation, post update etc.
I think this can be done by adding a script.php into the module zip file and then calling it in the installation file.
<scriptfile>script.php</scriptfile>
in the xml file to set up the script.
In the script.php I've some test type stuff:
<?php
// No direct access to this file
defined('_JEXEC') or die;
/**
* Script file of HelloWorld module
*/
class mod_W4cAccordionDisplayInstallerScript
{
/**
* Method to install the extension
* $parent is the class calling this method
*
* @return void
*/
function install($parent)
{
echo '<p>The module has been installed</p>';
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update('#__update_sites')
->set('extra_query = "ids=12354"')
->where('name = "Accordian Display"');
$db->setQuery($query);
$db->execute();
}
/**
* Method to uninstall the extension
* $parent is the class calling this method
*
* @return void
*/
function uninstall($parent)
I haven't copied the whole file since it's basically a copy of the joomla example.
When I run this by updating in the update then it says installation complete but it doesn't adjust the update sites table.
Any ideas where I might be going wrong
So I've now changed out the database update for
mail("[email protected]","My subject","user id is: ");
and put it into function postflight($type, $parent)
but there is no email response - I think that it's not loading and running the script :(
Figured it out - I had the wrong class name. I had removed all the _ characters like you normally do for class names but apparently you don't for this script. Hope this helps someone else. Thanks for the thoughts.