簡體   English   中英

如何在joomla中通過數據庫修改模板參數

[英]How to modify template params via database in joomla

我想通過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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM