SilverStripe\Subsites\Model\Subsite
A dynamically created subsite. SiteTree objects can now belong to a subsite.
You can simulate subsite access without setting up virtual hosts by appending ?SubsiteID=<ID> to the request.
Synopsis
class Subsite
extends DataObject
{
- // members
- private static string $table_name = 'Subsite';
- public static boolean $disable_subsite_filter = false;
- public static $force_subsite = NULL;
- private static boolean $write_hostmap = true;
- protected static array $cache_accessible_sites = ;
- protected static array $cache_subsite_for_domain = ;
- protected static array $allowed_themes = ;
- private static boolean $strict_subdomain_matching = false;
- private static boolean $check_is_public = true;
- private static array $summary_fields = ;
- private static array $db = ;
- private static array $has_many = ;
- private static array $belongs_many_many = ;
- private static array $defaults = ;
- private static array $searchable_fields = ;
- private static string $default_sort = '"Title" ASC';
- // methods
- public static void set_allowed_themes()
- public static DataObject currentSubsite()
- public static int currentSubsiteID()
- public static void changeSubsite()
- public static int getSubsiteIDForDomain()
- public static DataList get_from_all_subsites()
- public static void disable_subsite_filter()
- public static void on_db_reset()
- public static SS_List all_sites()
- public static void all_accessible_sites()
- public static DataList|ArrayList accessible_sites()
- public static void writeHostMap()
- public static bool hasMainSitePermission()
- public bool canEdit()
- public FieldList getCMSFields()
- public array getPageTypeMap()
- public array fieldLabels()
- public array allowedThemes()
- public string getLanguage()
- public ValidationResult validate()
- public void onAfterWrite()
- protected void createDefaultPages()
- public string domain()
- public SubsiteDomain getPrimarySubsiteDomain()
- public string getPrimaryDomain()
- public string absoluteBaseURL()
- public string adminDuplicate()
- public void activate()
- public DataList getMembersByPermission()
- public DataObject duplicate()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Tasks
Line | Task |
---|---|
612+ | Allow permission inheritance through group hierarchy. |
668+ | Possible security issue, don't grant edit permissions to everybody. |
Members
private
- $belongs_many_many — array
- $check_is_public
—
boolean
Respects the IsPublic flag when retrieving subsites - $db — array
- $default_sort — string
- $defaults — array
- $has_many — array
- $searchable_fields — array
- $strict_subdomain_matching
—
boolean
If set to TRUE, don't assume 'www.example.com' and 'example.com' are the same. - $summary_fields — array
- $table_name
- $write_hostmap
—
boolean
Whether to write a host-map.php file
protected
- $allowed_themes
—
array
Numeric array of all themes which are allowed to be selected for all subsites. -
$cache_accessible_sites
Memory cache of accessible sites - $cache_subsite_for_domain
—
array
Memory cache of subsite id for domains
public
- $disable_subsite_filter — boolean
-
$force_subsite
Allows you to force a specific subsite ID, or comma separated list of IDs.
Methods
protected
- createDefaultPages() — Automatically create default pages for new subsites
public
- absoluteBaseURL() — Get the absolute URL for this subsite
- accessible_sites() — Return the subsites that the current user can access by given permission.
- activate() — Make this subsite the current one
- adminDuplicate() — Javascript admin action to duplicate this subsite
- all_accessible_sites()
- all_sites() — Return all subsites, regardless of permissions (augmented with main site).
- allowedThemes() — Return the themes that can be used with this subsite, as an array of themecode => description
- canEdit()
- changeSubsite() — Switch to another subsite through storing the subsite identifier in the current PHP session.
- currentSubsite() — Gets the subsite currently set in the session.
- currentSubsiteID() — This function gets the current subsite ID from the session. It used in the backend so Ajax requests use the correct subsite. The frontend handles subsites differently. It calls getSubsiteIDForDomain directly from ModelAsController::getNestedController. Only gets Subsite instances which have their {@link IsPublic} flag set to TRUE.
- disable_subsite_filter() — Disable the sub-site filtering; queries will select from all subsites
- domain() — Return the primary domain of this site. Tries to "normalize" the domain name, by replacing potential wildcards.
- duplicate() — Duplicate this subsite
- fieldLabels()
- getCMSFields() — Show the configuration fields for each subsite
- getLanguage()
- getMembersByPermission()
- getPageTypeMap() — Return a list of the different page types available to the CMS
- getPrimaryDomain()
- getPrimarySubsiteDomain() — Finds the primary {@see SubsiteDomain} object for this subsite
- getSubsiteIDForDomain() — Get a matching subsite for the given host, or for the current HTTP_HOST.
- get_from_all_subsites()
- hasMainSitePermission() — Checks if a member can be granted certain permissions, regardless of the subsite context.
- onAfterWrite() — Whenever a Subsite is written, rewrite the hostmap and create some default pages
- on_db_reset() — Flush caches on database reset
- set_allowed_themes() — Set allowed themes
- validate()
- writeHostMap() — Write a host->domain map to subsites/host-map.php