douyalin2258 2017-03-16 09:33
浏览 45

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

I want to modify the current template params via database outside joomla framework. I managed to set the 'preset' param, but I can't write it back to the database. Here is my code.

Thanks a lot

// 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');
  • 写回答

1条回答 默认 最新

  • dqdes60666 2018-08-06 18:51
    关注
    $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();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)