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


PHP BaseElementModel::getAncestors方法代碼示例

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


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

示例1: getAttributes

 /**
  * Get entry attributes.
  *
  * @param array            $map
  * @param BaseElementModel $element
  *
  * @return array
  */
 public function getAttributes(array $map, BaseElementModel $element)
 {
     $attributes = array();
     // Try to parse checked fields through prepValue
     foreach ($map as $handle => $data) {
         if ($data['checked'] && !strstr($handle, ExportModel::HandleTitle)) {
             try {
                 $attributes[$handle] = $element->{$handle};
             } catch (\Exception $e) {
                 $attributes[$handle] = null;
             }
         }
     }
     // Title placeholder for all element types
     foreach (craft()->sections->getEntryTypesBySectionId($element->sectionId) as $entrytype) {
         // Set title
         $attributes[ExportModel::HandleTitle . '_' . $entrytype->id] = $entrytype->id == $element->typeId ? $element->{ExportModel::HandleTitle} : '';
     }
     // Get parent for structures
     if (array_key_exists(ExportModel::HandleParent, $map)) {
         $attributes[ExportModel::HandleParent] = $element->getAncestors() ? $element->getAncestors(1)->first() : '';
     }
     // Get ancestors for structures
     if (array_key_exists(ExportModel::HandleAncestors, $map)) {
         $attributes[ExportModel::HandleAncestors] = $element->getAncestors() ? implode('/', $element->getAncestors()->find()) : '';
     }
     // Call hook allowing 3rd-party plugins to modify attributes
     craft()->plugins->call('modifyExportAttributes', array(&$attributes, $element));
     return $attributes;
 }
開發者ID:transomdesign,項目名稱:transom-craft-starter,代碼行數:38,代碼來源:Export_EntryService.php

示例2: getAncestors

 /**
  * Returns the block's ancestors.
  *
  * @param int|null $dist
  * @return ElementCriteriaModel
  */
 public function getAncestors($dist = null)
 {
     // If the request is in Live Preview mode, use the Neo-extended criteria model, which supports Live Preview mode
     if (craft()->neo->isPreviewMode()) {
         if (!isset($this->_liveCriteria['ancestors'])) {
             $criteria = craft()->neo->getCriteria();
             $criteria->setAllElements($this->_allElements);
             $criteria->ancestorOf = $this;
             $this->_liveCriteria['ancestors'] = $criteria;
         }
         if ($dist) {
             return $this->_liveCriteria['ancestors']->ancestorDist($dist);
         }
         return $this->_liveCriteria['ancestors'];
     }
     return parent::getAncestors($dist);
 }
開發者ID:benjamminf,項目名稱:craft-neo,代碼行數:23,代碼來源:Neo_BlockModel.php

示例3: getAttributes

 /**
  * Get category attributes.
  *
  * @param array            $map
  * @param BaseElementModel $element
  *
  * @return array
  */
 public function getAttributes(array $map, BaseElementModel $element)
 {
     $attributes = array();
     // Try to parse checked fields through prepValue
     foreach ($map as $handle => $data) {
         if ($data['checked']) {
             try {
                 $attributes[$handle] = $element->{$handle};
             } catch (\Exception $e) {
                 $attributes[$handle] = null;
             }
         }
     }
     // Get parent for categories
     if (array_key_exists(ExportModel::HandleParent, $map)) {
         $attributes[ExportModel::HandleParent] = $element->getAncestors() ? $element->getAncestors(1)->first() : '';
     }
     // Get ancestors for categories
     if (array_key_exists(ExportModel::HandleAncestors, $map)) {
         $attributes[ExportModel::HandleAncestors] = $element->getAncestors() ? implode('/', $element->getAncestors()->find()) : '';
     }
     // Call hook allowing 3rd-party plugins to modify attributes
     craft()->plugins->call('modifyExportAttributes', array(&$attributes, $element));
     return $attributes;
 }
開發者ID:transomdesign,項目名稱:transom-craft-starter,代碼行數:33,代碼來源:Export_CategoryService.php

示例4: getAttributes

 /**
  * Get category attributes.
  *
  * @param array            $map
  * @param BaseElementModel $element
  *
  * @return array
  */
 public function getAttributes(array $map, BaseElementModel $element)
 {
     $attributes = array();
     // Try to parse checked fields through prepValue
     foreach ($map as $handle => $data) {
         if ($data['checked']) {
             $attributes[$handle] = $element->{$handle};
         }
     }
     // Get parent for categories
     if (array_key_exists(ExportModel::HandleParent, $map)) {
         if ($element->getAncestors()) {
             $attributes[ExportModel::HandleParent] = $element->getAncestors(1)->first();
         }
     }
     // Get ancestors for categories
     if (array_key_exists(ExportModel::HandleAncestors, $map)) {
         if ($element->getAncestors()) {
             $attributes[ExportModel::HandleAncestors] = implode('/', $element->getAncestors()->find());
         }
     }
     return $attributes;
 }
開發者ID:webremote,項目名稱:export,代碼行數:31,代碼來源:Export_CategoryService.php


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