我需要安装我在 joomla 2.5 版本上创建的组件。安装要求我在默认模板 (templates/templatename/html/com_test/viewname/default.php) 中添加一个 html 文件夹,以便覆盖另一个组件。那么如何在安装 xml 或 instalation.php 脚本中指定在 joomla 安装的默认模板中添加包含一些其他文件夹和文件的文件夹?
我还需要提到这是我的installation.php 文件的代码。这就是我到目前为止所做的,但我仍然无法弄清楚为什么该文件夹没有被复制。我认为源代码错误,因为它位于我要安装的 zip 文件中
<?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>';
}
}