本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}