本文整理汇总了PHP中ElementHelper::setUniqueUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementHelper::setUniqueUri方法的具体用法?PHP ElementHelper::setUniqueUri怎么用?PHP ElementHelper::setUniqueUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElementHelper
的用法示例。
在下文中一共展示了ElementHelper::setUniqueUri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrl
/**
* Returns the element's full URL.
*
* @return string
*/
public function getUrl()
{
if ($this->uri === null) {
ElementHelper::setUniqueUri($this);
}
return parent::getUrl();
}
示例2: updateElementSlugAndUri
/**
* Updates an element’s slug and URI, along with any descendants.
*
* @param BaseElementModel $element The element to update.
* @param bool $updateOtherLocales Whether the element’s other locales should also be updated.
* @param bool $updateDescendants Whether the element’s descendants should also be updated.
* @param bool $asTask Whether the element’s slug and URI should be updated via a background task.
*
* @return null
*/
public function updateElementSlugAndUri(BaseElementModel $element, $updateOtherLocales = true, $updateDescendants = true, $asTask = false)
{
if ($asTask) {
craft()->tasks->createTask('UpdateElementSlugsAndUris', null, array('elementId' => $element->id, 'elementType' => $element->getElementType(), 'locale' => $element->locale, 'updateOtherLocales' => $updateOtherLocales, 'updateDescendants' => $updateDescendants));
return;
}
ElementHelper::setUniqueUri($element);
craft()->db->createCommand()->update('elements_i18n', array('slug' => $element->slug, 'uri' => $element->uri), array('elementId' => $element->id, 'locale' => $element->locale));
// Delete any caches involving this element
craft()->templateCache->deleteCachesByElement($element);
if ($updateOtherLocales) {
$this->updateElementSlugAndUriInOtherLocales($element);
}
if ($updateDescendants) {
$this->updateDescendantSlugsAndUris($element, $updateOtherLocales);
}
}
示例3: updateElementSlugAndUri
/**
* Updates an element’s slug and URI, along with any descendants.
*
* @param BaseElementModel $element The element to update.
* @param bool $updateOtherLocales Whether the element’s other locales should also be updated.
* @param bool $updateDescendants Whether the element’s descendants should also be updated.
*
* @return null
*/
public function updateElementSlugAndUri(BaseElementModel $element, $updateOtherLocales = true, $updateDescendants = true)
{
ElementHelper::setUniqueUri($element);
craft()->db->createCommand()->update('elements_i18n', array('slug' => $element->slug, 'uri' => $element->uri), array('elementId' => $element->id, 'locale' => $element->locale));
// Delete any caches involving this element
craft()->templateCache->deleteCachesByElement($element);
if ($updateOtherLocales) {
$this->updateElementSlugAndUriInOtherLocales($element);
}
if ($updateDescendants) {
$this->updateDescendantSlugsAndUris($element);
}
}