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


PHP FrontendTemplate::getContent方法代码示例

本文整理汇总了PHP中FrontendTemplate::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP FrontendTemplate::getContent方法的具体用法?PHP FrontendTemplate::getContent怎么用?PHP FrontendTemplate::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrontendTemplate的用法示例。


在下文中一共展示了FrontendTemplate::getContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent

 /**
  * Get parsed template content
  *
  * @return string
  */
 public function getContent()
 {
     return $this->tpl->getContent($this->templatePath, false, true);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:9,代码来源:base.php

示例2: getNavigationHTML

 /**
  * Get navigation HTML
  *
  * @return	string
  * @param	string[optional] $type			The type of navigation the HTML should be build for.
  * @param	int[optional] $parentId			The parentID to start of.
  * @param	int[optional] $depth			The maximum depth to parse.
  * @param	array[optional] $excludeIds		PageIDs to be excluded.
  * @param	bool[optional] $includeChildren	Children can be included regardless of whether we're at the current page.
  * @param	int[optional] $depthCounter		A counter that will hold the current depth.
  */
 public static function getNavigationHTML($type = 'page', $parentId = 0, $depth = null, $excludeIds = array(), $includeChildren = false, $depthCounter = 1)
 {
     // get navigation
     $navigation = self::getNavigation();
     // meta-navigation is requested but meta isn't enabled
     if ($type == 'meta' && !FrontendModel::getModuleSetting('pages', 'meta_navigation', true)) {
         return '';
     }
     // validate
     if (!isset($navigation[$type])) {
         throw new FrontendException('This type (' . $type . ') isn\'t a valid navigation type. Possible values are: page, footer, meta.');
     }
     if (!isset($navigation[$type][$parentId])) {
         throw new FrontendException('The parent (' . $parentId . ') doesn\'t exists.');
     }
     // special construction to merge home with it's immediate children
     $mergedHome = false;
     while (true) {
         // loop elements
         foreach ($navigation[$type][$parentId] as $id => $page) {
             // home is a special item, it should live on the same depth
             if ($page['page_id'] == 1 && !$mergedHome) {
                 // extra checks otherwise exceptions will wbe triggered.
                 if (!isset($navigation[$type][$parentId]) || !is_array($navigation[$type][$parentId])) {
                     $navigation[$type][$parentId] = array();
                 }
                 if (!isset($navigation[$type][$page['page_id']]) || !is_array($navigation[$type][$page['page_id']])) {
                     $navigation[$type][$page['page_id']] = array();
                 }
                 // add children
                 $navigation[$type][$parentId] = array_merge($navigation[$type][$parentId], $navigation[$type][$page['page_id']]);
                 // mark as merged
                 $mergedHome = true;
                 // restart loop
                 continue 2;
             }
             // not hidden
             if ($page['hidden']) {
                 unset($navigation[$type][$parentId][$id]);
                 continue;
             }
             // some ids should be excluded
             if (in_array($page['page_id'], (array) $excludeIds)) {
                 unset($navigation[$type][$parentId][$id]);
                 continue;
             }
             // if the item is in the selected page it should get an selected class
             if (in_array($page['page_id'], self::$selectedPageIds)) {
                 $navigation[$type][$parentId][$id]['selected'] = true;
             } else {
                 $navigation[$type][$parentId][$id]['selected'] = false;
             }
             // add nofollow attribute if needed
             if ($page['no_follow']) {
                 $navigation[$type][$parentId][$id]['nofollow'] = true;
             } else {
                 $navigation[$type][$parentId][$id]['nofollow'] = false;
             }
             // has children and is selected and is desired?
             if (isset($navigation[$type][$page['page_id']]) && $page['page_id'] != 1 && ($navigation[$type][$parentId][$id]['selected'] == true || $includeChildren) && ($depth == null || $depthCounter + 1 <= $depth)) {
                 $navigation[$type][$parentId][$id]['children'] = self::getNavigationHTML($type, $page['page_id'], $depth, $excludeIds, $includeChildren, $depthCounter + 1);
             } else {
                 $navigation[$type][$parentId][$id]['children'] = false;
             }
             // add parent id
             $navigation[$type][$parentId][$id]['parent_id'] = $parentId;
             // add depth
             $navigation[$type][$parentId][$id]['depth'] = $depth;
             // set link
             $navigation[$type][$parentId][$id]['link'] = FrontendNavigation::getURL($page['page_id']);
             // is this an internal redirect?
             if (isset($page['redirect_page_id']) && $page['redirect_page_id'] != '') {
                 $navigation[$type][$parentId][$id]['link'] = FrontendNavigation::getURL((int) $page['redirect_page_id']);
             }
             // is this an external redirect?
             if (isset($page['redirect_url']) && $page['redirect_url'] != '') {
                 $navigation[$type][$parentId][$id]['link'] = $page['redirect_url'];
             }
         }
         // break the loop (it is only used for the special construction with home)
         break;
     }
     // create template
     $tpl = new FrontendTemplate(false);
     // assign navigation to template
     $tpl->assign('navigation', $navigation[$type][$parentId]);
     // return parsed content
     return $tpl->getContent(self::$templatePath, true, true);
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:100,代码来源:navigation.php

示例3: getTemplateContent

 /**
  * Returns the content from a given template
  *
  * @return	string
  * @param	string $template				The template to use.
  * @param	array[optional] $variables		The variabled to assign.
  */
 private static function getTemplateContent($template, $variables = null)
 {
     // new template instance
     $tpl = new FrontendTemplate(false);
     // set some options
     $tpl->setForceCompile(true);
     // variables were set
     if (!empty($variables)) {
         $tpl->assign($variables);
     }
     // grab the content
     $content = $tpl->getContent($template);
     // replace internal links/images
     $search = array('href="/', 'src="/');
     $replace = array('href="' . SITE_URL . '/', 'src="' . SITE_URL . '/');
     $content = str_replace($search, $replace, $content);
     // require CSSToInlineStyles
     require_once 'external/css_to_inline_styles.php';
     // create instance
     $cssToInlineStyles = new CSSToInlineStyles();
     // set some properties
     $cssToInlineStyles->setHTML($content);
     $cssToInlineStyles->setUseInlineStylesBlock(true);
     $cssToInlineStyles->setEncoding(SPOON_CHARSET);
     // return the content
     return (string) $cssToInlineStyles->convert();
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:34,代码来源:mailer.php


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