Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在joomla中通过数据库修改模板参数_Php_Templates_Joomla - Fatal编程技术网

Php 如何在joomla中通过数据库修改模板参数

Php 如何在joomla中通过数据库修改模板参数,php,templates,joomla,Php,Templates,Joomla,我想通过joomla框架外的数据库修改当前模板参数。我设法设置了“预设”参数,但无法将其写回数据库。这是我的密码 非常感谢 // Initialize The Joomla Framework // ----------------------------------------------------------------------------------- define('_JEXEC', 1); // this is relative to the current script, s

我想通过joomla框架外的数据库修改当前模板参数。我设法设置了“预设”参数,但无法将其写回数据库。这是我的密码

非常感谢

// Initialize The Joomla Framework
// -----------------------------------------------------------------------------------
define('_JEXEC', 1);

// this is relative to the current script, so change this according to your environment
define('JPATH_BASE', '/home/kristof/public_html/joomla1'); 
define('DS', DIRECTORY_SEPARATOR);

// Require Joomla libraries
require_once(JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once(JPATH_BASE . DS . 'includes' . DS . 'framework.php');
require_once(JPATH_CONFIGURATION . DS . 'configuration.php');
require_once(JPATH_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'database.php');
require_once(JPATH_LIBRARIES . DS . 'import.php');
// -----------------------------------------------------------------------------------

$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
$param=$template->params->set('preset','preset3');
$template = JFactory::getApplication('site')->getTemplate();
    $db = JFactory::getDBO();
    $sql = "select params from #__template_styles where template = ".$db->quote($template);
    $db->setQuery($sql);
    $params = json_decode($db->loadResult());
    $params->PARAM_NAME= PARAM_VALUE;

    $sql = "update #__template_styles set params = ".$db->quote(json_encode($params))." where template = ".$db->quote($template);
    $db->setQuery($sql);
    return $db->query();