I need to install a component I created on my joomla 2.5 version.
The instalation requiers me to add an html folder in the default template (templates/templatename/html/com_test/viewname/default.php) in order to overide another component.
So how can I specify in the instalation xml or in the instalation.php script
to add a folder containing some other folders and files in the default template of the joomla instalation?
I also need to mention that this is the code of my installation.php file.This is how I have made it so far but still I cant figure out why the folder is not coppied. I think the source is wrong since it is in the zip file that I am trying to install
<?php
defined('_JEXEC') or die('Restricted access');
/**
* Script file of HelloWorld component
*/
class com_helloWorldInstallerScript
{
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
$db = JFactory::getDBO();
$query = "
SELECT ".$db->nameQuote('template')."
FROM ".$db->nameQuote('#__template_styles')."
WHERE ".$db->nameQuote('client_id')." = 1 and ".$db->nameQuote('home')." = 1;
";
$db->setQuery($query);
$AdminTemplate = $db->loadResult();
$query = "
SELECT ".$db->nameQuote('template')."
FROM ".$db->nameQuote('#__template_styles')."
WHERE ".$db->nameQuote('client_id')." = 0 and ".$db->nameQuote('home')." = 1;
";
$db->setQuery($query);
$SiteTemplate = $db->loadResult();
$src = "/viewnamenew";
$destination = JPATH_SITE."/templates/".$SiteTemplate ."/html/com_test/viewname";
JFolder::copy($src, $destination);
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_HELLOWORLD_UNINSTALL_TEXT') . '</p>';
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_HELLOWORLD_UPDATE_TEXT') . '</p>';
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
function preflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_HELLOWORLD_PREFLIGHT_' . $type . '_TEXT') . '</p>';
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_HELLOWORLD_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
}
}
You will need to use a installation.php file.
If you want to create a folder and then copy files inside of it, it will go something along these lines
JPATH_SITE is just the Joomla default directory. $src is the directory of the file you’ve installed with the component and $dest is going to be JPATH_SITE.”/templates/templatename/html/com_test/viewname” again.
Alternatively (and probably better) you can just write the files inside installation.php by:
And this will create the folders necessary, without having to use JFolder at all.
Please note if you are creating some folders thought, you should put in some blank index.html files – although you should be easily able to copy some of these from your component!
Hope this helps