Version: current

# Class VirtualPage

Virtual Page creates an instance of a page, with the same fields that the original page had, but readonly. This allows you can have a page in mulitple places in the site structure, with different children without duplicating the content Note: This Only duplicates $db fields and not the $has_one etc..

  Object
  ViewableData implements IteratorAggregate
  DataObject implements DataObjectInterface, i18nEntityProvider
  SiteTree implements PermissionProvider, i18nEntityProvider
  Page
  VirtualPage

### Direct known subclasses

`SubsitesVirtualPage`, `VirtualProduct`

Package: cms
Located at sapphire/core/model/VirtualPage.php

## Methods summary

`public` | # `getVirtualFields( )` Generates the array of fields required for the page type. Generates the array of fields required for the page type.
`public` | # `CopyContentFrom( )`
`public` | # `setCopyContentFromID( mixed $val )`
`public `SiteTree`` | # `ContentSource( )` Returns the object that contains the content that a user would associate with this page. Returns the object that contains the content that a user would associate with this page. Ordinarily, this is just the page itself, but for example on RedirectorPages or VirtualPages ContentSource() will return the page that is linked to. #### Returns ``SiteTree`` The content source. #### Overrides `SiteTree::ContentSource`
`public array` | # `allowedChildren( )` Returns an array of the class names of classes that are allowed to be children of this class. Returns an array of the class names of classes that are allowed to be children of this class. #### Returns `array` array #### Overrides `SiteTree::allowedChildren`
`public` | # `syncLinkTracking( )` #### Overrides `SiteTree::syncLinkTracking`
`public `Boolean`` | # `canPublish( `Member` $member = null )` We can only publish the page if there is a published source page We can only publish the page if there is a published source page #### Parameters $member Member $member #### Returns ``Boolean`` Boolean #### Overrides `Page::canPublish`
`public` | # `canDeleteFromLive( mixed $member = null )` Return true if we can delete this page from the live site, which is different from can we publish it. Return true if we can delete this page from the live site, which is different from can we publish it. #### Overrides `Page::canDeleteFromLive`
`public` | # `isPublishable( )` Returns true if is page is publishable by anyone at all Return false if the source page isn't published yet. Returns true if is page is publishable by anyone at all Return false if the source page isn't published yet. Note that isPublishable doesn't affect ete from live, only publish.
`public `FieldSet`` | # `getCMSFields( mixed $cms = null )` Generate the CMS fields from the fields from the original page. Generate the CMS fields from the fields from the original page. #### Returns ``FieldSet`` The fields to be displayed in the CMS. #### Overrides `Page::getCMSFields`
`public` | # `onBeforeWrite( )` We have to change it to copy all the content from the original page first. We have to change it to copy all the content from the original page first. #### Overrides `Page::onBeforeWrite`
`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! 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! #### Uses ``DataObjectDecorator::onAfterWrite()`` #### Overrides `Page::onAfterWrite`
`public` | # `copyFrom( mixed $source, mixed $updateImageTracking = true )` Ensure we have an up-to-date version of everything. Ensure we have an up-to-date version of everything.
`public` | # `updateImageTracking( )`
`public mixed` | # `__get( string $field )` Allow attributes on the master page to pass through to the virtual page Allow attributes on the master page to pass through to the virtual page #### Parameters $field string $field #### Returns `mixed` mixed #### Overrides `ViewableData::__get`
`public mixed` | # `__call( string $method, string $args )` Pass unrecognized method calls on to the original data object Pass unrecognized method calls on to the original data object #### Parameters $method string $method $args string $args #### Returns `mixed` mixed #### Overrides `Object::__call`
`public boolean` | # `hasField( string $field )` Returns true if the given field exists in a database column on any of the objects tables, or as a dynamic getter with get<fieldName>(). Returns true if the given field exists in a database column on any of the objects tables, or as a dynamic getter with get<fieldName>(). #### Parameters $field string $field Name of the field #### Returns `boolean` True if the given field exists #### Overrides `DataObject::hasField`
`public boolean` | # `hasMethod( string $method )` Overwrite to also check for method on the original data object Overwrite to also check for method on the original data object #### Parameters $method string $method #### Returns `boolean` bool #### Overrides `Object::hasMethod`

### Methods inherited from Page

`AdminEmail()`, `DevMode()`, `FinalParent()`, `Lang()`, `Locale()`, `MetaTags()`, `NestedValue()`, `allowComments()`, `canAddChildren()`, `canDelete()`, `canEdit()`, `checkDevPermisson()`, `hiddenCMSFields()`, `hide_cms_fields()`, `onAfterDelete()`, `populateDefaults()`, `set_hidden_cms_fields()`

### Methods inherited from SiteTree

`AbsoluteLink()`, `Breadcrumbs()`, `CMSTreeClasses()`, `Comments()`, `DependentPages()`, `DependentPagesCount()`, `ElementName()`, `InSection()`, `Level()`, `Link()`, `LinkOrCurrent()`, `LinkOrSection()`, `LinkingMode()`, `NestedTitle()`, `RelativeLink()`, `TreeTitle()`, `VirtualPages()`, `batch_permission_check()`, `can()`, `canCreate()`, `canView()`, `can_delete_multiple()`, `can_edit_multiple()`, `cmsCleanup_parentChanged()`, `collateDescendants()`, `defaultChild()`, `defaultParent()`, `disableCMSFieldsExtensions()`, `disable_nested_urls()`, `doDeleteFromLive()`, `doPublish()`, `doRestoreToStage()`, `doRevertToLive()`, `doRollbackTo()`, `doUnpublish()`, `duplicate()`, `duplicateAsChild()`, `duplicateWithChildren()`, `enableCMSFieldsExtensions()`, `enable_nested_urls()`, `fieldLabels()`, `generateURLSegment()`, `generate_homepage_domain_map()`, `getAbsoluteLiveLink()`, `getCMSActions()`, `getClassDropdown()`, `getExistsOnLive()`, `getIsAddedToStage()`, `getIsDeletedFromStage()`, `getIsModifiedOnStage()`, `getMenuTitle()`, `getParent()`, `getParentType()`, `getSiteConfig()`, `get_by_link()`, `get_enforce_strict_hierarchy()`, `i18n_singular_name()`, `isCurrent()`, `isNew()`, `isPublished()`, `isSection()`, `link_shortcode_handler()`, `nested_urls()`, `onBeforeDelete()`, `page_type_classes()`, `prepopuplate_permission_cache()`, `provideI18nEntities()`, `providePermissions()`, `requireDefaultRecords()`, `reset()`, `rewriteFileURL()`, `setMenuTitle()`, `setParent()`, `set_enforce_strict_hierarchy()`, `validURLSegment()`

### 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()`, `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()`, `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()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`

### Methods inherited from Object

`__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()`, `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 string|array` | $icon | # Icon to use in the CMS Icon to use in the CMS This should be the base filename. The suffixes -file.gif, openfolder.gif and -closedfolder.gif will be appended to the base name that you provide there. If you prefer, you can pass an array: array("sapphire\thirdparty\tree\images\page", $option). $option can be either "file" or "folder" to force the icon to always be a file or folder, regardless of whether the page has children or not
`public static mixed` | $virtualFields | #
`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 `DataObject::$belongs_to` relationship on the child class. 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 `DataObject::$belongs_to` relationship on the child class. Note that you cannot have a has_one and belongs_to relationship with the same name.
`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 . Database field definitions. This is a map from field names to field type. The field type should be a class that extends .

### Properties inherited from Page

`$default_child`, `$defaults`, `$hidden_cms_fields`, `$summary_fields`

### Properties inherited from SiteTree

`$allowed_children`, `$belongs_many_many`, `$breadcrumbs_delimiter`, `$cache_permissions`, `$can_be_root`, `$can_create`, `$casting`, `$default_parent`, `$default_sort`, `$extensions`, `$has_many`, `$hide_ancestor`, `$indexes`, `$many_many`, `$many_many_extraFields`, `$need_permission`, `$searchable_fields`, `$versioning`, `$write_homepage_map`

### 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`

### Properties inherited from ViewableData

`$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -