Class SiteTree
Basic data-object representing all pages within the site tree. This data-object takes care of the heirachy. All page types that live within the heirachy should inherit from this.
In addition, it contains a number of static methods for querying the site tree.
- Object
-
ViewableData
implements
IteratorAggregate
-
DataObject
implements
DataObjectInterface,
i18nEntityProvider
-
SiteTree
implements
PermissionProvider,
i18nEntityProvider
Direct known subclasses
Indirect known subclasses
Announcement,
AnnouncementHolder,
DocumentsPage,
ErrorPage,
Event,
EventHolder,
FaqHolder,
FaqSection,
Guestbook,
HomePage,
MapObject,
MapObjectGroup,
BaseObjectCategory,
MapPage,
MediawebPage,
NewsEntry,
NewsHolder,
PhotoAlbumPage,
PhotoGalleryPage,
Product,
ProductSearchPage,
ProfilePage,
PublHolder,
BookingAdminPage,
Publication,
RedirectorPage,
RegistrationPage,
Room,
RoomCatalog,
SimpleOrderPage,
SpecialCatalog,
StartCatalog,
SubscribeForm,
SubsitesSelectorPage,
BookingPage,
SubsitesVirtualPage,
UserDefinedForm,
VideoBankPage,
VirtualPage,
VirtualProduct,
CartPage,
Catalog,
CheckoutPage,
ContactsPage,
DocPage
Methods summary
public static
|
|
public static
|
|
public static
boolean
|
#
nested_urls( )
Returns TRUE if nested URLs (e.g. page/sub-page/) are currently enabled on this site. |
public static
|
|
public static
|
|
public static
|
#
get_by_link( string $link, boolean $cache = true )
Fetches the |
public static
array
|
#
page_type_classes( )
Return a subclass map of SiteTree that shouldn't be hidden through |
public static
string
|
#
link_shortcode_handler( mixed $arguments, mixed $content = null, mixed $parser = null )
Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID. |
public
string
|
#
Link( string $action = null )
Return the link for this |
public
string
|
#
AbsoluteLink( string $action = null )
Get the absolute URL for this page, including protocol and host. |
public
string
|
#
RelativeLink( string $action = null )
Return the link for this |
public
|
#
getAbsoluteLiveLink( mixed $includeStageEqualsLive = true )
Get the absolute URL for this page on the Live site. |
public
string
|
|
public
boolean
|
|
public
boolean
|
|
public
string
|
#
LinkOrCurrent( )
Return "link" or "current" depending on if this is the |
public
string
|
#
LinkOrSection( )
Return "link" or "section" depending on if this is the SiteTree::isSeciton() current section. |
public
string
|
#
LinkingMode( )
Return "link", "current" or section depending on if this page is the current page, or not on the current page but in the current section. |
public
boolean
|
|
public
|
|
public
boolean
|
|
public
|
|
public
|
#
duplicateWithChildren( )
Duplicates each child of this node recursively and returns the duplicate node. |
public
|
#
duplicateAsChild( integer $id )
Duplicate this node and its children as a child of the node with the given ID |
public
string
|
#
Breadcrumbs( integer $maxDepth = 20, boolean $unlinked = false, string $stopAtPageType = false, boolean $showHidden = false )
Return a breadcrumb trail to this page. Excludes "hidden" pages (with ShowInMenus=0). |
public
|
|
public
|
|
public
string
|
#
NestedTitle( integer $level = 2, string $separator = " - " )
Return a string of the form "parent - page" or "grandparent - parent - page". |
public
boolean
|
|
public
boolean
|
#
canAddChildren( mixed $member = null )
This function should return true if the current user can add children to this page. It can be overloaded to customise the security model for an application. |
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
public
boolean
|
#
canPublish(
This function should return true if the current user can publish this page. It can be overloaded to customise the security model for an application. |
public
|
|
public
|
|
public static
|
#
prepopuplate_permission_cache( mixed $permission = 'CanEditType', mixed $ids, mixed $batchCallback = null )
Pre-populate the cache of canEdit, canView, canDelete, canPublish permissions. This method will use the static can_(perm)_multiple method for efficiency. |
public static
|
#
batch_permission_check( mixed $ids, mixed $memberID, mixed $typeField, mixed $groupJoinTable, mixed $siteConfigMethod, mixed $globalPermission = 'CMS_ACCESS_CMSMain', mixed $useCached = true )
|
public static
A
|
#
can_edit_multiple( An $ids, useCached $memberID, mixed $useCached = true )
Get the 'can edit' information for a number of SiteTree pages. |
public static
|
#
can_delete_multiple( An $ids, useCached $memberID, mixed $useCached = true )
Get the 'can edit' information for a number of SiteTree pages. |
public
|
#
collateDescendants( string $condition, array & $collator )
Collate selected descendants of this page. |
public
string
|
|
public
|
#
ContentSource( )
Returns the object that contains the content that a user would associate with this page. |
public
|
|
protected
|
#
onBeforeWrite( )
Event handler called before writing to the database. You can overload this to clean up or otherwise process data before writing it to the database. Don't forget to call parent::onBeforeWrite(), though! |
public
|
|
public
|
#
onAfterWrite( )
Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! |
public
|
#
onBeforeDelete( )
Event handler called before deleting from the database. You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though! |
public
|
|
public
boolean
|
#
validURLSegment( )
Returns TRUE if this object has a URLSegment value that does not conflict
with any other objects. This methods checks for: |
public
string
|
|
public
|
#
rewriteFileURL( mixed $old, mixed $new )
Rewrite a file URL on this page, after its been renamed. Triggers the onRenameLinkedAsset action on extensions. |
public
|
#
DependentPages( mixed $includeVirtuals = true )
Returns the pages that depend on this page. This includes virtual pages, pages that link to it, etc. |
public
|
#
DependentPagesCount( mixed $includeVirtuals = true )
Return the number of |
public
|
|
public
|
|
public
array|string
|
|
public
|
|
public
|
|
public static
|
|
public
|
|
public
|
#
doRollbackTo( mixed $version )
Roll the draft version of this page to match the published page. Caution: Doesn't overwrite the object properties with the rolled back version. |
public
|
|
public
The
|
#
doRestoreToStage( )
Restore the content in the active copy of this SiteTree page to the stage site. |
public
|
|
public
boolean
|
|
public
boolean
|
|
protected
array
|
#
getClassDropdown( )
Get the class dropdown used in the CMS to change the class of a page. This returns the list of options in the drop as a Map from class name to text in dropdown. |
public
array
|
#
allowedChildren( )
Returns an array of the class names of classes that are allowed to be children of this class. |
public
string
|
|
public
string
|
|
public
|
#
cmsCleanup_parentChanged( )
Function to clean up the currently loaded page after a reorganise has been called. It should return a piece of JavaScript to be executed on the client side, to clean up the results of the reorganise. |
public
string
|
#
getMenuTitle( )
Get the title for use in menus for this page. If the MenuTitle field is set it returns that, else it returns the Title field. |
public
|
|
public
string
|
|
public
|
|
public
string
|
#
CMSTreeClasses(
Return the CSS classes to apply to this node in the CMS tree |
public
boolean
|
#
getIsDeletedFromStage( )
Compares current draft with live version, and returns TRUE if no draft version of this page exists, but the page is still published (after triggering "Delete from draft site" in the CMS). |
public
|
|
public
boolean
|
#
getIsModifiedOnStage( )
Compares current draft with live version, and returns TRUE if these versions differ, meaning there have been unpublished changes to the draft site. |
public
boolean
|
#
getIsAddedToStage( )
Compares current draft with live version, and returns true if no live version exists, meaning the page was never published. |
public static
|
#
disableCMSFieldsExtensions( )
Stops extendCMSFields() being called on getCMSFields(). This is useful when you need access to fields added by subclasses of SiteTree in a decorator. Call before calling parent::getCMSFields(), and reenable afterwards. |
public static
|
#
enableCMSFieldsExtensions( )
Reenables extendCMSFields() being called on getCMSFields() after it has been disabled by disableCMSFieldsExtensions(). |
public
|
#
providePermissions( )
Return a map of permission codes to add to the dropdown shown in the Security
section of the CMS. array( |
public
String
|
|
public
array
|
#
provideI18nEntities( )
Overloaded to also provide entities for 'Page' class which is usually located in custom code, hence textcollector picks it up for the wrong folder. |
public
|
|
public static
|
Methods inherited from DataObject
Aggregate(),
RelationshipAggregate(),
__construct(),
baseTable(),
belongs_to(),
buildDataObjectSet(),
buildSQL(),
castedUpdate(),
composite_fields(),
context_obj(),
customDatabaseFields(),
custom_database_fields(),
data(),
databaseFields(),
databaseIndexes(),
database_extensions(),
database_fields(),
db(),
dbObject(),
debug(),
defaultSearchFilters(),
defineMethods(),
delete(),
delete_by_id(),
destroy(),
disable_subclass_access(),
enable_subclass_access(),
exists(),
extendedSQL(),
fieldLabel(),
flushCache(),
flush_and_destroy_cache(),
forceChange(),
get(),
getAllFields(),
getChangedFields(),
getClassAncestry(),
getComponent(),
getComponents(),
getComponentsQuery(),
getDefaultSearchContext(),
getField(),
getFrontEndFields(),
getManyManyComponents(),
getManyManyComponentsQuery(),
getManyManyFilter(),
getManyManyJoin(),
getRemoteJoinField(),
getReverseAssociation(),
getTitle(),
get_by_id(),
get_one(),
get_validation_enabled(),
hasDatabaseField(),
hasField(),
hasOwnTableDatabaseField(),
hasValue(),
has_many(),
has_one(),
has_own_table(),
i18n_plural_name(),
inheritedDatabaseFields(),
instance_get(),
instance_get_one(),
isChanged(),
isEmpty(),
isInDB(),
is_composite_field(),
many_many(),
many_many_extraFields(),
merge(),
newClassInstance(),
plural_name(),
populateDefaults(),
relObject(),
requireTable(),
scaffoldFormFields(),
scaffoldSearchFields(),
searchableFields(),
setCastedField(),
setClassName(),
setComponent(),
setField(),
set_context_obj(),
set_validation_enabled(),
singular_name(),
summaryFields(),
toMap(),
update(),
validate(),
write(),
writeComponents(),
writeWithoutVersion()
Methods inherited from ViewableData
ATT_val(),
BaseHref(),
CSSClasses(),
ColumnBreak(),
ColumnCalc(),
ColumnNumber(),
ColumnPad(),
ColumnPos(),
CurrentMember(),
CurrentPage(),
Debug(),
Even(),
EvenOdd(),
First(),
FirstLast(),
HasPerm(),
IsAjax(),
JS_val(),
Last(),
Me(),
Middle(),
MiddleString(),
Modulus(),
MultipleOf(),
Odd(),
Pos(),
RAW_val(),
SQL_val(),
ThemeDir(),
ThemeName(),
Top(),
TotalItems(),
XML_val(),
__get(),
__isset(),
__set(),
buildCastingCache(),
cachedCall(),
castingClass(),
castingHelper(),
castingHelperPair(),
castingObjectCreator(),
castingObjectCreatorPair(),
customise(),
escapeTypeForField(),
getIterator(),
getSecurityID(),
getXMLValues(),
i18nLocale(),
iteratorProperties(),
obj(),
renderWith(),
setCustomisedObj()
Methods inherited from Object
__call(),
__toString(),
__wakeup(),
addMethodsFrom(),
addStaticVars(),
addWrapperMethod(),
add_extension(),
add_static_var(),
allMethodNames(),
cacheToFile(),
cacheToFileWithArgs(),
clearCache(),
combined_static(),
create(),
createMethod(),
create_from_string(),
extInstance(),
extend(),
getCustomClass(),
getExtensionInstance(),
getExtensionInstances(),
get_extensions(),
get_static(),
hasExtension(),
hasMethod(),
has_extension(),
invokeWithExtensions(),
is_a(),
loadCache(),
parentClass(),
parse_class_spec(),
remove_extension(),
sanitiseCachename(),
saveCache(),
set_stat(),
set_static(),
set_uninherited(),
stat(),
strong_create(),
uninherited(),
uninherited_static(),
useCustomClass()
Magic methods summary
Properties summary
public static
array
|
$allowed_children |
#
Indicates what kind of children this page type can have. This can be an array of allowed child classes, or the string "none" - indicating that this page type can't have children. If a classname is prefixed by "*", such as "*Page", then only that class is allowed - no subclasses. Otherwise, the class and all its subclasses are allowed. |
public static
string
|
$default_child |
#
The default child class for this page. |
public static
string
|
$default_parent |
#
The default parent class for this page. |
public static
boolean
|
$can_be_root |
#
Controls whether a page can be in the root of the site tree. |
public static
array
|
$need_permission |
#
List of permission codes a user can have to allow a user to create a page of this type. |
public static
string
|
$hide_ancestor |
#
If you extend a class, and don't want to be able to select the old class in the cms, set this to the old class name. Eg, if you extended Product to make ImprovedProduct, then you would set $hide_ancestor to Product. |
public static
array
|
$db |
#
Database field definitions. This is a map from field names to field type. The field type should be a class that extends . |
public static
array
|
$indexes |
#
If a field is in this array, then create a database index on that field. This is a map from fieldname to index type. See SS_Database->requireIndex() and custom subclasses for details on the array notation. |
public static
array
|
$has_many |
#
This defines a one-to-many relationship. It is a map of component name to the remote data class. |
public static
array
|
$many_many |
#
many-many relationship definitions. This is a map from component name to data type. |
public static
array
|
$belongs_many_many |
#
The inverse side of a many-many relationship. This is a map from component name to data type. |
public static
array
|
$many_many_extraFields |
#
Extra fields to include on the connecting many-many table. This is a map from field name to field type. |
public static
array
|
$casting |
#
Use a casting object for a field. This is a map from field name to class name of the casting object. |
public static
array
|
$defaults |
#
Inserts standard column-values when a DataObject is instanciated. Does not
insert default records |
public static
array
|
$has_one |
#
One-to-zero relationship defintion. This is a map of component name to data
type. In order to turn this into a true one-to-one relationship you can add a
|
public static
array
|
$versioning | |
public static
string
|
$default_sort |
#
The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. |
public static
boolean
|
$can_create |
#
If this is false, the class cannot be created in the CMS. |
public static
string|array
|
$icon |
#
Icon to use in the CMS |
public static
array
|
$extensions |
#
An array of extension names and parameters to be applied to this object upon construction. |
public static
string
|
$breadcrumbs_delimiter |
#
Delimit breadcrumb-links generated by BreadCrumbs() |
public static
boolean
|
$write_homepage_map |
#
Whether or not to write the homepage map for static publisher |
public static
array
|
$searchable_fields |
#
Default list of fields that can be scaffolded by the ModelAdmin search interface. |
public static
array
|
$cache_permissions |
#
Cache for canView/Edit/Publish/Delete permissions |
Properties inherited from DataObject
$allowed_actions,
$ancestry,
$api_access,
$belongs_to,
$brokenOnDelete,
$brokenOnWrite,
$cache_get_one,
$cache_has_own_table,
$cache_has_own_table_field,
$componentCache,
$components,
$create_table_options,
$default_records,
$destroyed,
$field_labels,
$original,
$plural_name,
$record,
$singular_name,
$summary_fields
Properties inherited from ViewableData
$customisedObject,
$default_cast,
$failover,
$iteratorPos,
$iteratorTotalItems