获取模板作者和许可证

问题描述 投票:0回答:1

基于此示例代码,在Joomla 3.9.5上

$app            = JFactory::getApplication();
$getTemplateId  = $app->getTemplate('template')->id;

我正在尝试从XML / SQLdb获取模板作者和许可证

$app                = JFactory::getApplication();
$getTemplateAuthor  = $app->getTemplate('template')->author;
$getTemplateLicense = $app->getTemplate('template')->license;

这当然不起作用所以我对任何建议都很满意。

php joomla3.0
1个回答
0
投票

在phpMyAdmin中调查数据库之后,我想出了这个解决方案

// get app
$app = JFactory::getApplication();
// get template
$templateName = $app->getTemplate();
// hook Joomla Database API
$db = JFactory::getDbo();
// set query
$db->setQuery("SELECT manifest_cache FROM #__extensions where `type` = 'template' AND `element` = '".$templateName."'");
// extract the manifest_cache column
$templateMETA = $db->loadObject()->manifest_cache; 
// decode JSON and build an object
$templateMETA = json_decode( $templateMETA );
// set author&license
$author = $templateMETA->author;
$license = $templateMETA->license;

manifest_cache保存模板,可能还有任何Joomla扩展元信息。

希望这有助于某人。

© www.soinside.com 2019 - 2024. All rights reserved.