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