ElementHelper

Type
Class
Namespace
Craft
Inherits
Craft\ElementHelper
Since
2.0

Class ElementHelper

See also http://craftcms.com

View source (opens new window)

# Public Methods

Method Description
createSlug() Creates a slug based on a given string.
doesUrlFormatHaveSlugTag() Returns whether a given URL format has a proper {slug} tag.
getEditableLocaleIdsForElement() Returns the editable locale IDs for a given element, taking user locale permissions into account.
isElementEditable() Returns whether the given element is editable by the current user, taking user locale permissions into account.
setNextPrevOnElements() Given an array of elements, will go through and set the appropriate "next" and "prev" elements on them.
setUniqueUri() Sets the URI on an element using a given URL format, tweaking its slug if necessary to ensure it's unique.
setValidSlug() Sets a valid slug on a given element.

# createSlug()

Creates a slug based on a given string.

View source (opens new window)

Arguments

Returns

string (opens new window)

Signature

public static string createSlug ( $str )

# doesUrlFormatHaveSlugTag()

Returns whether a given URL format has a proper {slug} tag.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public static boolean doesUrlFormatHaveSlugTag ( $urlFormat )

# getEditableLocaleIdsForElement()

Returns the editable locale IDs for a given element, taking user locale permissions into account.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public static array getEditableLocaleIdsForElement ( Craft\BaseElementModel $element )

# isElementEditable()

Returns whether the given element is editable by the current user, taking user locale permissions into account.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public static boolean isElementEditable ( Craft\BaseElementModel $element )

# setNextPrevOnElements()

Given an array of elements, will go through and set the appropriate "next" and "prev" elements on them.

View source (opens new window)

Arguments

Signature

public static void setNextPrevOnElements ( $elements )

# setUniqueUri()

Sets the URI on an element using a given URL format, tweaking its slug if necessary to ensure it's unique.

View source (opens new window)

Arguments

Throws

Signature

public static void setUniqueUri ( Craft\BaseElementModel $element )

# setValidSlug()

Sets a valid slug on a given element.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null setValidSlug ( Craft\BaseElementModel $element )