当前位置: 首页>>代码示例>>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;未经允许,请勿转载。