本文整理汇总了PHP中BaseElementModel::getSection方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::getSection方法的具体用法?PHP BaseElementModel::getSection怎么用?PHP BaseElementModel::getSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterMoveElementInStructure
/**
* @inheritDoc IElementType::onAfterMoveElementInStructure()
*
* @param BaseElementModel $element
* @param int $structureId
*
* @return null|void
*/
public function onAfterMoveElementInStructure(BaseElementModel $element, $structureId)
{
// Was the entry moved within its section's structure?
$section = $element->getSection();
if ($section->type == SectionType::Structure && $section->structureId == $structureId) {
craft()->elements->updateElementSlugAndUri($element, true, true, true);
}
}
示例2: routeRequestForMatchedElement
/**
* Routes the request when the URI matches an element.
*
* @param BaseElementModel
* @return mixed Can be false if no special action should be taken,
* a string if it should route to a template path,
* or an array that can specify a controller action path, params, etc.
*/
public function routeRequestForMatchedElement(BaseElementModel $element)
{
// Make sure that the entry is actually live
if ($element->getStatus() == EntryModel::LIVE) {
$section = $element->getSection();
// Make sure the section is set to have URLs and is enabled for this locale
if ($section->hasUrls && array_key_exists(craft()->language, $section->getLocales())) {
return array('action' => 'templates/render', 'params' => array('template' => $section->template, 'variables' => array('entry' => $element)));
}
}
return false;
}