當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Navigation::getFirstChildId方法代碼示例

本文整理匯總了PHP中Frontend\Core\Engine\Navigation::getFirstChildId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Navigation::getFirstChildId方法的具體用法?PHP Navigation::getFirstChildId怎麽用?PHP Navigation::getFirstChildId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Frontend\Core\Engine\Navigation的用法示例。


在下文中一共展示了Navigation::getFirstChildId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPageContent

 /**
  * Get page content
  */
 protected function getPageContent()
 {
     // load revision
     if ($this->URL->getParameter('page_revision', 'int') != 0) {
         // get data
         $this->record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
         // add no-index to meta-custom, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         // get page record
         $this->record = (array) Model::getPage($this->pageId);
     }
     // empty record (pageId doesn't exists, hope this line is never used)
     if (empty($this->record) && $this->pageId != 404) {
         \SpoonHTTP::redirect(Navigation::getURL(404), 404);
     }
     // init var
     $redirect = true;
     // loop blocks, if all are empty we should redirect to the first child
     foreach ($this->record['positions'] as $blocks) {
         // loop blocks in position
         foreach ($blocks as $block) {
             // HTML provided?
             if ($block['html'] != '') {
                 $redirect = false;
             }
             // an decent extra provided?
             if ($block['extra_type'] == 'block') {
                 $redirect = false;
             }
             // a widget provided
             if ($block['extra_type'] == 'widget') {
                 $redirect = false;
             }
         }
     }
     // should we redirect?
     if ($redirect) {
         // get first child
         $firstChildId = Navigation::getFirstChildId($this->record['id']);
         // validate the child
         if ($firstChildId !== false) {
             // build URL
             $URL = Navigation::getURL($firstChildId);
             // redirect
             \SpoonHTTP::redirect($URL, 301);
         }
     }
 }
開發者ID:arashrasoulzadeh,項目名稱:forkcms,代碼行數:52,代碼來源:Page.php

示例2: getPageContent

 /**
  * Get page content
  *
  * @param $pageId
  *
  * @return array
  * @throws RedirectException
  */
 protected function getPageContent($pageId)
 {
     // load revision
     if ($this->URL->getParameter('page_revision', 'int') != 0) {
         // get data
         $record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
         // add no-index to meta-custom, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         // get page record
         $record = (array) Model::getPage($pageId);
     }
     if (empty($record)) {
         return array();
     }
     // init var
     $redirect = true;
     // loop blocks, if all are empty we should redirect to the first child
     foreach ($record['positions'] as $blocks) {
         // loop blocks in position
         foreach ($blocks as $block) {
             // HTML provided?
             if ($block['html'] != '') {
                 $redirect = false;
             }
             // an decent extra provided?
             if ($block['extra_type'] == 'block') {
                 $redirect = false;
             }
             // a widget provided
             if ($block['extra_type'] == 'widget') {
                 $redirect = false;
             }
         }
     }
     // should we redirect?
     if ($redirect) {
         // get first child
         $firstChildId = Navigation::getFirstChildId($record['id']);
         // validate the child
         if ($firstChildId !== false) {
             // build URL
             $url = Navigation::getURL($firstChildId);
             // redirect
             throw new RedirectException('Redirect', new RedirectResponse($url, 301));
         }
     }
     return $record;
 }
開發者ID:forkcms,項目名稱:forkcms,代碼行數:57,代碼來源:Page.php


注:本文中的Frontend\Core\Engine\Navigation::getFirstChildId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。