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


PHP PageModel::findFirstPublishedRootByHostAndLanguage方法代码示例

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


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

示例1: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     if (is_null($objPage) || TL_MODE == 'BE') {
         $objPage = \PageModel::findFirstPublishedRootByHostAndLanguage(\Environment::get('host'), 'de');
     }
     // Limit the total number of items (see #2652)
     if ($this->numberOfItems > 0) {
         $this->arrImages = array_slice($this->arrImages, 0, $this->numberOfItems);
     }
     $offset = 0;
     $total = count($this->arrImages);
     $limit = $total;
     $rowcount = 0;
     $colwidth = floor(100 / $this->perRow);
     $intMaxWidth = TL_MODE == 'BE' ? floor(640 / $this->perRow) : floor(\Config::get('maxImageWidth') / $this->perRow);
     $body = array();
     // Rows
     for ($i = $offset; $i < $limit; $i = $i + $this->perRow) {
         $class_tr = '';
         if ($rowcount == 0) {
             $class_tr .= ' row_first';
         }
         if ($i + $this->perRow >= $limit) {
             $class_tr .= ' row_last';
         }
         $class_eo = $rowcount % 2 == 0 ? ' even' : ' odd';
         // Columns
         for ($j = 0; $j < $this->perRow; $j++) {
             $class_td = '';
             if ($j == 0) {
                 $class_td .= ' col_first';
             }
             if ($j == $this->perRow - 1) {
                 $class_td .= ' col_last';
             }
             $objCell = new \stdClass();
             $key = 'row_' . $rowcount . $class_tr . $class_eo;
             // Empty cell
             if (!is_array($this->arrImages[$i + $j]) || $j + $i >= $limit) {
                 $objCell->colWidth = $colwidth . '%';
                 $objCell->class = 'col_' . $j . $class_td;
             } else {
                 $this->addImageToTemplate($objCell, $this->arrImages[$i + $j], $intMaxWidth, $strLightboxId);
                 // Add column width and class
                 $objCell->href = $this->arrImages[$i + $j]['imageUrl'];
                 $objCell->colWidth = $colwidth . '%';
                 $objCell->class = 'col_' . $j . $class_td;
             }
             $body[$key][$j] = $objCell;
         }
         ++$rowcount;
     }
     $this->Template->body = $body;
 }
开发者ID:davidenke,项目名称:newsletter_content,代码行数:58,代码来源:ContentGallery.php

示例2: modifyCacheKey

 /**
  * Modify the cached key
  *
  * @param string $key
  *
  * @return string
  */
 public function modifyCacheKey($key)
 {
     if ($GLOBALS['objPage']->rootId) {
         // The page is being cached
         $rootPage = \PageModel::findByPk($GLOBALS['objPage']->rootId);
     } else {
         // Page loaded from cache, global $objPage not available
         $rootPage = \PageModel::findFirstPublishedRootByHostAndLanguage(\Environment::get('host'), $GLOBALS['TL_LANGUAGE']);
     }
     if ($rootPage !== null) {
         $key .= $this->isCookiebarEnabled($rootPage) ? '_cookiebar' : '';
     }
     return $key;
 }
开发者ID:codefog,项目名称:contao-cookiebar,代码行数:21,代码来源:CookieBar.php

示例3: getRootPageFromUrl

 /**
  * Try to find a root page based on language and URL
  * @return \Model
  */
 public static function getRootPageFromUrl()
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getRootPageFromUrl']) && is_array($GLOBALS['TL_HOOKS']['getRootPageFromUrl'])) {
         foreach ($GLOBALS['TL_HOOKS']['getRootPageFromUrl'] as $callback) {
             if (is_object($objRootPage = static::importStatic($callback[0])->{$callback}[1]())) {
                 return $objRootPage;
             }
         }
     }
     $host = \Environment::get('host');
     // The language is set in the URL
     if ($GLOBALS['TL_CONFIG']['addLanguageToUrl'] && !empty($_GET['language'])) {
         $objRootPage = \PageModel::findFirstPublishedRootByHostAndLanguage($host, \Input::get('language'));
         // No matching root page found
         if ($objRootPage === null) {
             header('HTTP/1.1 404 Not Found');
             \System::log('No root page found (host "' . $host . '", language "' . \Input::get('language') . '"', 'Frontend getRootPageFromUrl()', TL_ERROR);
             die('No root page found');
         }
     } else {
         $accept_language = \Environment::get('httpAcceptLanguage');
         // Find the matching root pages (thanks to Andreas Schempp)
         $objRootPage = \PageModel::findFirstPublishedRootByHostAndLanguage($host, $accept_language);
         // No matching root page found
         if ($objRootPage === null) {
             header('HTTP/1.1 404 Not Found');
             \System::log('No root page found (host "' . \Environment::get('host') . '", languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '")', 'Frontend getRootPageFromUrl()', TL_ERROR);
             die('No root page found');
         }
         // Redirect to the language root (e.g. en/)
         if ($GLOBALS['TL_CONFIG']['addLanguageToUrl'] && !$GLOBALS['TL_CONFIG']['doNotRedirectEmpty'] && \Environment::get('request') == '') {
             static::redirect((!$GLOBALS['TL_CONFIG']['rewriteURL'] ? 'index.php/' : '') . $objRootPage->language . '/', 302);
         }
     }
     return $objRootPage;
 }
开发者ID:rburch,项目名称:core,代码行数:41,代码来源:Frontend.php


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