本文整理匯總了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;
}