当前位置: 首页>>代码示例>>PHP>>正文


PHP T3::setTemplate方法代码示例

本文整理汇总了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();
         }
     }
 }
开发者ID:ITPrism,项目名称:SocialCommunityDistribution,代码行数:101,代码来源:bot.php


注:本文中的T3::setTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。