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


PHP Director::currentPage方法代碼示例

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


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

示例1: recordPageID

 private function recordPageID()
 {
     $currentPage = Director::currentPage();
     if ($currentPage) {
         $this->PageID = $currentPage->ID;
     }
 }
開發者ID:ramziammar,項目名稱:websites,代碼行數:7,代碼來源:PageView.php

示例2: getBlogHolder

	function getBlogHolder() {
		$page = Director::currentPage();
		
		if($page->is_a("BlogHolder")) {
			return $page;
		} else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
			return $page->getParent();
		} else {
			return DataObject::get_one("BlogHolder");
		}
	}
開發者ID:neopba,項目名稱:silverstripe-book,代碼行數:11,代碼來源:BlogManagementWidget.php

示例3: getBlogHolder

	function getBlogHolder() {
		$page = Director::currentPage();
		
		if($page instanceof BlogHolder) {
			return $page;
		} elseif(($page instanceof BlogEntry) && ($page->getParent() instanceof BlogHolder)) {
			return $page->getParent();
		} else {
			return DataObject::get_one('BlogHolder');
		}
	}
開發者ID:neopba,項目名稱:silverstripe-book,代碼行數:11,代碼來源:ArchiveWidget.php

示例4: addPage

 static function addPage()
 {
     $historyString = Session::get("LastPagesVisited");
     $historyArray = unserialize($historyString);
     if (!is_array($historyArray)) {
         $historyArray = array();
     }
     $page = Director::currentPage();
     if ($page) {
         $pageID = $page->ID;
         if ($pageID) {
             if (!in_array($pageID, $historyArray)) {
                 array_unshift($historyArray, $pageID);
                 if (count($historyArray) > self::$number_of_pages_back) {
                     array_pop($historyArray);
                 }
             } elseif ($historyArray[count($historyArray) - 1] == $pageID) {
                 array_pop($historyArray);
                 array_unshift($historyArray, $pageID);
             }
         }
     }
     Session::set("LastPagesVisited", serialize($historyArray));
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-widgets-latestpagesvisited,代碼行數:24,代碼來源:LatestPagesVisitedWidget.php

示例5: prepareCurrentAndSection

 /**
  * This function is used for isCurrent() and isSection() to prepare
  * the cached answers.
  */
 protected function prepareCurrentAndSection()
 {
     if (!self::$currentPageID) {
         self::$currentPageID = Director::currentPage() ? Director::currentPage()->ID : null;
         if (!isset(self::$currentPageID)) {
             self::$currentPageID = -1;
             $nextID = Director::currentPage() && isset(Director::currentPage()->Parent->ID) ? Director::currentPage()->Parent->ID : null;
         } else {
             $nextID = SiteTree::$currentPageID;
         }
         $table = Versioned::current_stage() == "Live" ? "SiteTree_Live" : "SiteTree";
         SiteTree::$currentSectionIDs = array();
         while ($nextID) {
             self::$currentSectionIDs[] = $nextID;
             $nextID = DB::query("SELECT ParentID FROM SiteTree WHERE ID = {$nextID}")->value();
         }
     }
 }
開發者ID:ramziammar,項目名稱:websites,代碼行數:22,代碼來源:SiteTree.php

示例6: prepareCurrentAndSection

	/**
	 * This function is used for isCurrent() and isSection() to prepare
	 * the cached answers.
	 */
	protected function prepareCurrentAndSection() {
		if(!self::$currentPageID || Director::urlParam('URLSegment') != self::$currentPageIDSetFromURLSegment) {
			self::$currentPageID = Director::currentPage() ? Director::currentPage()->ID : null;
			self::$currentPageIDSetFromURLSegment = Director::urlParam('URLSegment');
			
			if(!isset(self::$currentPageID)) {
				self::$currentPageID = -1;
				$nextID = (Director::currentPage() && isset(Director::currentPage()->Parent->ID))
					? Director::currentPage()->Parent->ID
					: null;
			} else {
				$nextID = SiteTree::$currentPageID;
			}

			$table = (Versioned::current_stage() == "Live")
				? "SiteTree_Live"
				: "SiteTree";

			SiteTree::$currentSectionIDs = array();
			while($nextID) {
				self::$currentSectionIDs[] = $nextID;
				$nextID = DB::query("SELECT ParentID FROM SiteTree WHERE ID = $nextID")->value();
			}
		}
	}
開發者ID:neopba,項目名稱:silverstripe-book,代碼行數:29,代碼來源:SiteTree.php


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