Hierarchy
class Hierarchy extends DataExtension
DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most obvious example of this is SiteTree.
Config options
node_threshold_total | int | The lower bounds for the amount of nodes to mark. If set, the logic will expand nodes until it reaches at least this number, and then stops. Root nodes will always show regardless of this settting. Further nodes can be lazy-loaded via ajax. This isn't a hard limit. Example: On a value of 10, with 20 root nodes, each having 30 children, the actual node count will be 50 (all root nodes plus first expanded child). | |
node_threshold_leaf | int | Limit on the maximum children a specific node can display. Serves as a hard limit to avoid exceeding available server resources in generating the tree, and browser resources in rendering it. Nodes with children exceeding this value typically won't display any children, although this is configurable through the $nodeCountCallback parameter in {@link getChildrenAsUL()}. "Root" nodes will always show all children, regardless of this setting. | |
hide_from_hierarchy | array | A list of classnames to exclude from display in both the CMS and front end displays. ->Children() and ->AllChildren affected. | |
hide_from_cms_tree | array | A list of classnames to exclude from display in the page tree views of the CMS, unlike $hide_from_hierarchy above which effects both CMS and front end. |
Properties
$class | from Extension |
Methods
Called when this extension is added to a particular class
Helper method to strip eval'ed arguments from a string thats passed to {@link DataObject::$extensions} or {@link Object::add_extension()}.
No description
Validate the owner object - check for existence of infinite loops.
Define extra database fields
This function is used to provide modifications to the form in the CMS by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
This function is used to provide modifications to the form used for front end forms. {@link DataObject->getFrontEndFields()}
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']
this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']
Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child, so if they have children they will be displayed as a UL inside a LI.
Mark a segment of the tree, by calling mark().
Filter the marking to only those object with $node->$parameterName == $parameterValue
Filter the marking to only those where the function returns true. The node in question will be passed to the function.
Returns true if the marking filter matches on the given node.
Mark all children of the given node that match the marking filter.
Return CSS classes of 'unexpanded', 'closed', both, or neither, as well as a 'jstree-*' state depending on the marking of this DataObject.
Mark the children of the DataObject with the given ID.
Expose the given object in the tree, by marking this page and all it ancestors.
Return the IDs of all the marked nodes.
Return an array of this page and its ancestors, ordered item -> root.
Mark this DataObject as expanded.
Mark this DataObject as unexpanded.
Mark this DataObject's tree as opened.
Mark this DataObject's tree as closed.
Check if this DataObject is marked.
Check if this DataObject is expanded.
Check if this DataObject's tree is opened.
Get a list of this DataObject's and all it's descendants IDs.
Get a list of this DataObject's and all it's descendants ID, and put them in $idList.
Return all children, including those 'not in menus'.
Return all children, including those that have been deleted but are still in live.
No description
Return all the children that this page had, including pages that were deleted from both stage & live.
Return the number of children that this page ever had, including pages that were deleted.
Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by {@link augmentNumChildrenCountQuery()}.
Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
Return children in the stage site.
Return children in the live site, if it exists.
Get this object's parent, optionally filtered by an SQL clause. If the clause doesn't match the parent, nothing is returned.
Return all the parents of this class in a set ordered from the lowest to highest parent.
Returns a human-readable, flattened representation of the path to the object, using its {@link Title} attribute.
Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents.
Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents.
Flush all Hierarchy caches: - Children (instance) - NumChildren (instance) - Marked (global) - Expanded (global) - TreeOpened (global)
Reset global Hierarchy caches: - Marked - Expanded - TreeOpened
Details
in Extension at line 42
__construct()
in Extension at line 54
static
add_to_class(string $class, string $extensionClass, mixed $args = null)
Called when this extension is added to a particular class
in Extension at line 66
setOwner(SS_Object $owner, string $ownerBaseClass = null)
Set the owner of this extension.
in Extension at line 74
clearOwner()
in Extension at line 97
static string
get_classname_without_arguments(string $extensionStr)
Helper method to strip eval'ed arguments from a string thats passed to {@link DataObject::$extensions} or {@link Object::add_extension()}.
at line 70
static
get_extra_config($class, $extension, $args)
in DataExtension at line 32
static
unload_extra_statics($class, $extension)
at line 81
validate(ValidationResult $validationResult)
Validate the owner object - check for existence of infinite loops.
in DataExtension at line 50
augmentSQL(SQLQuery $query)
Edit the given query object to support queries for this extension
in DataExtension at line 59
augmentDatabase()
Update the database schema as required by this extension.
When duplicating a table's structure, remember to duplicate the create options as well. See {@link Versioned->augmentDatabase} for an example.
in DataExtension at line 67
augmentWrite(array $manipulation)
Augment a write-record request.
in DataExtension at line 70
onBeforeWrite()
in DataExtension at line 73
onAfterWrite()
in DataExtension at line 76
onBeforeDelete()
in DataExtension at line 79
onAfterDelete()
in DataExtension at line 82
requireDefaultRecords()
in DataExtension at line 85
populateDefaults()
in DataExtension at line 88
can($member)
in DataExtension at line 91
canEdit($member)
in DataExtension at line 94
canDelete($member)
in DataExtension at line 97
canCreate($member)
in DataExtension at line 112
array
extraStatics($class = null, $extension = null)
Define extra database fields
Return a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined.
in DataExtension at line 129
updateCMSFields(FieldList $fields)
This function is used to provide modifications to the form in the CMS by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
Please consider using {@link updateFormFields()} to globally add formfields to the record. The method {@link updateCMSFields()} should just be used to add or modify tabs, or fields which are specific to the CMS-context.
Caution: Use {@link FieldList->addFieldToTab()} to add fields.
in DataExtension at line 140
updateFrontEndFields(FieldList $fields)
This function is used to provide modifications to the form used for front end forms. {@link DataObject->getFrontEndFields()}
Caution: Use {@link FieldList->push()} to add fields.
in DataExtension at line 149
updateCMSActions(FieldList $actions)
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
in DataExtension at line 160
updateSummaryFields(array $fields)
this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']
in DataExtension at line 180
updateFieldLabels(array $labels)
this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']
at line 130
string
getChildrenAsUL($attributes = "", $titleEval = '"<li>" . $child->Title', $extraArg = null, $limitToMarked = false, $childrenMethod = "AllChildrenIncludingDeleted", $numChildrenMethod = "numChildren", $rootCall = true, $nodeCountThreshold = null, $nodeCountCallback = null)
Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child, so if they have children they will be displayed as a UL inside a LI.
at line 221
int
markPartialTree($nodeCountThreshold = null, $context = null, $childrenMethod = "AllChildrenIncludingDeleted", $numChildrenMethod = "numChildren")
Mark a segment of the tree, by calling mark().
The method performs a breadth-first traversal until the number of nodes is more than minCount. This is used to get a limited number of tree nodes to show in the CMS initially.
This method returns the number of nodes marked. After this method is called other methods can check {@link isExpanded()} and {@link isMarked()} on individual nodes.
at line 251
setMarkingFilter(string $parameterName, mixed $parameterValue)
Filter the marking to only those object with $node->$parameterName == $parameterValue
at line 264
setMarkingFilterFunction(string $funcName)
Filter the marking to only those where the function returns true. The node in question will be passed to the function.
at line 276
bool
markingFilterMatches(DataObject $node)
Returns true if the marking filter matches on the given node.
at line 308
DataList
markChildren(DataObject $node, mixed $context = null, string $childrenMethod = "AllChildrenIncludingDeleted", string $numChildrenMethod = "numChildren")
Mark all children of the given node that match the marking filter.
at line 360
string
markingClasses(string $numChildrenMethod = "numChildren")
Return CSS classes of 'unexpanded', 'closed', both, or neither, as well as a 'jstree-*' state depending on the marking of this DataObject.
at line 384
bool
markById(int $id, bool $open = false)
Mark the children of the DataObject with the given ID.
at line 401
markToExpose(DataObject $childObj)
Expose the given object in the tree, by marking this page and all it ancestors.
at line 415
array
markedNodeIDs()
Return the IDs of all the marked nodes.
at line 424
SiteTree[]
parentStack()
Return an array of this page and its ancestors, ordered item -> root.
at line 456
markExpanded()
Mark this DataObject as expanded.
at line 464
markUnexpanded()
Mark this DataObject as unexpanded.
at line 472
markOpened()
Mark this DataObject's tree as opened.
at line 480
markClosed()
Mark this DataObject's tree as closed.
at line 491
bool
isMarked()
Check if this DataObject is marked.
at line 502
bool
isExpanded()
Check if this DataObject is expanded.
at line 513
bool
isTreeOpened()
Check if this DataObject's tree is opened.
at line 524
int[]
getDescendantIDList()
Get a list of this DataObject's and all it's descendants IDs.
at line 535
loadDescendantIDListInto(array $idList)
Get a list of this DataObject's and all it's descendants ID, and put them in $idList.
at line 555
DataList
Children()
Get the children for this DataObject.
at line 574
DataList
AllChildren()
Return all children, including those 'not in menus'.
at line 588
ArrayList
AllChildrenIncludingDeleted(mixed $context = null)
Return all children, including those that have been deleted but are still in live.
- Deleted children will be marked as "DeletedFromStage"
- Added children will be marked as "AddedToStage"
- Modified children will be marked as "ModifiedOnStage"
- Everything else has "SameOnStage" set, as an indicator that this information has been looked up.
at line 598
ArrayList
doAllChildrenIncludingDeleted(mixed $context = null)
at line 633
DataList
AllHistoricalChildren()
Return all the children that this page had, including pages that were deleted from both stage & live.
at line 649
int
numHistoricalChildren()
Return the number of children that this page ever had, including pages that were deleted.
at line 665
int
numChildren(bool $cache = true)
Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by {@link augmentNumChildrenCountQuery()}.
at line 682
bool
showingCMSTree()
Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
at line 696
DataList
stageChildren(bool $showAll = false)
Return children in the stage site.
at line 725
DataList
liveChildren(bool $showAll = false, bool $onlyDeletedFromStage = false)
Return children in the live site, if it exists.
at line 758
DataObject
getParent(string $filter = null)
Get this object's parent, optionally filtered by an SQL clause. If the clause doesn't match the parent, nothing is returned.
at line 774
ArrayList
getAncestors()
Return all the parents of this class in a set ordered from the lowest to highest parent.
at line 791
string
getBreadcrumbs(string $separator = ' » ')
Returns a human-readable, flattened representation of the path to the object, using its {@link Title} attribute.
at line 809
DataObject
naturalPrev(string $className, DataObject $afterNode = null)
Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents.
at line 821
DataObject
naturalNext(string $className = null, string|int $root, DataObject $afterNode = null)
Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents.
at line 874
flushCache()
Flush all Hierarchy caches: - Children (instance) - NumChildren (instance) - Marked (global) - Expanded (global) - TreeOpened (global)
at line 888
static
reset()
Reset global Hierarchy caches: - Marked - Expanded - TreeOpened