本文整理汇总了PHP中T3::setTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP T3::setTemplate方法的具体用法?PHP T3::setTemplate怎么用?PHP T3::setTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类T3
的用法示例。
在下文中一共展示了T3::setTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterInit
//.........这里部分代码省略.........
}
}
}
// update the order of items
$_items = array();
$_itemsids = array();
$firstitem = 0;
foreach ($children[$id] as $child) {
$_itemsids[] = (int) $child->id;
if (!$firstitem) {
$firstitem = (int) $child->id;
}
if (in_array($child->id, $items)) {
$_items[] = (int) $child->id;
}
}
// $_items[0] = $firstitem;
if (empty($_items) || $_items[0] != $firstitem) {
if (count($_items) == count($items)) {
$_items[0] = $firstitem;
} else {
array_splice($_items, 0, 0, $firstitem);
}
}
// no need update config for this item
if ($items == $_items) {
continue;
}
// update back to setting
$i = 0;
$c = count($_items);
for ($j = 0; $j < count($sub['rows']); $j++) {
for ($k = 0; $k < count($sub['rows'][$j]); $k++) {
if (!isset($sub['rows'][$j][$k]['position'])) {
$sub['rows'][$j][$k]['item'] = $i < $c ? $_items[$i++] : "";
}
}
}
//update - add new rows for new items - at the first rows
if (!empty($_items) && count($items) == 0) {
$modify = true;
array_unshift($sub['rows'], array(array('item' => $_items[0], 'width' => 12)));
}
//check and remove any empty row
for ($j = 0; $j < count($sub['rows']); $j++) {
$remove = true;
for ($k = 0; $k < count($sub['rows'][$j]); $k++) {
if (isset($sub['rows'][$j][$k]['position']) || in_array($sub['rows'][$j][$k]['item'], $_itemsids)) {
$remove = false;
break;
}
}
if ($remove) {
$modify = true;
unset($sub['rows'][$j]);
}
}
if ($modify) {
$sub['rows'] = array_values($sub['rows']);
//re-index
}
$mmconfig[$item]['sub'] = $sub;
}
}
$currentconfig[$menukey] = $mmconfig;
}
// update megamenu back to other template styles parameter
$mm_config = json_encode($currentconfig);
// update megamenu back to current template style parameter
$template = $app->getTemplate(true);
$params = $template->params;
$params->set('mm_config', $mm_config);
$template->params = $params;
//update the cache
T3::setTemplate(T3_TEMPLATE, $params);
//get all other styles that have the same template
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')->from('#__template_styles')->where('template=' . $db->quote(T3_TEMPLATE))->where('client_id=0');
$db->setQuery($query);
$themes = $db->loadObjectList();
//update all global parameters
foreach ($themes as $theme) {
$registry = new JRegistry();
$registry->loadString($theme->params);
$registry->set('mm_config', $mm_config);
//overwrite with new value
$registry->set('mm_config_needupdate', "");
//overwrite with new value
$query = $db->getQuery(true);
$query->update('#__template_styles')->set('params =' . $db->quote($registry->toString()))->where('id =' . (int) $theme->id);
$db->setQuery($query);
$db->execute();
}
// force reload cache template
$cache = JFactory::getCache('com_templates', '');
$cache->clean();
}
}
}