Piwik\
Provides access to individual site entity data (including name, URL, etc.).
Data Cache
Site data can be cached in order to avoid performing too many queries. If a method needs many site entities, it is more efficient to query all of what you need beforehand via the SitesManager API, then cache it using setSites() or setSitesFromArray().
Subsequent calls to new Site($id) will use the data in the cache instead of querying the database.
Basic usage
$site = new Site($idSite);
$name = $site->getName();
Without allocation
$name = Site::getNameFor($idSite);
The class defines the following methods:
__construct() — Constructor.setSites() — Sets the cached site data with an array that associates site IDs with individual site data.__toString() — Returns a string representation of the site this instance references.getName() — Returns the name of the site.getMainUrl() — Returns the main url of the site.getId() — Returns the id of the site.getType() ash; Returns the website type (by default "website", which means it is a single website).getCreationDate() — Returns the creation date of the site.getTimezone() — Returns the timezone of the size.getCurrency() — Returns the currency of the site.getExcludedIps() — Returns the excluded ips of the site.getExcludedQueryParameters() — Returns the excluded query parameters of the site.isEcommerceEnabled() — Returns whether ecommerce is enabled for the site.getSearchKeywordParameters() — Returns the site search keyword query parameters for the site.getSearchCategoryParameters() — Returns the site search category query parameters for the site.isSiteSearchEnabled() — Returns whether Site Search Tracking is enabled for the site.getCreatorLogin() — Returns the user that created this site.getIdSitesFromIdSitesString() — Checks the given string for valid site IDs and returns them as an array.clearCache() — Clears the site data cache.clearCacheForSite() — Clears the site data cache.getNameFor() — Returns the name of the site with the specified ID.getGroupFor() — Returns the group of the site with the specified ID.getTimezoneFor() — Returns the timezone of the site with the specified ID.getTypeFor() — Returns the type of the site with the specified ID.getCreationDateFor() — Returns the creation date of the site with the specified ID.getMainUrlFor() — Returns the url for the site with the specified ID.isEcommerceEnabledFor() — Returns whether the site with the specified ID is ecommerce enabled or not.isSiteSearchEnabledFor() — Returns whether the site with the specified ID is Site Search enabled.getCurrencyFor() — Returns the currency of the site with the specified ID.getCurrencySymbolFor() — Returns the currency of the site with the specified ID.getExcludedIpsFor() — Returns the excluded IP addresses of the site with the specified ID.getExcludedQueryParametersFor() — Returns the excluded query parameters for the site with the specified ID.getCreatorLoginFor() — Returns the user that created this site.__construct()Constructor.
$idsite (int) —
The ID of the site we want data for.Piwik\Exception\UnexpectedWebsiteFoundExceptionsetSites()Sets the cached site data with an array that associates site IDs with individual site data.
$sites (array) —
The array of sites data. Indexed by site ID. eg, array('1' => array('name' => 'Site 1', ...), '2' => array('name' => 'Site 2', ...))`__toString()Returns a string representation of the site this instance references.
Useful for debugging.
string value.getName()Returns the name of the site.
string value.Exception — if data for the site cannot be found.getMainUrl()Returns the main url of the site.
string value.Exception — if data for the site cannot be found.getId()Returns the id of the site.
int value.Exception — if data for the site cannot be found.getType()Returns the website type (by default "website", which means it is a single website).
string value.getCreationDate()Returns the creation date of the site.
Date value.Exception — if data for the site cannot be found.getTimezone()Returns the timezone of the size.
string value.Exception — if data for the site cannot be found.getCurrency()Returns the currency of the site.
string value.Exception — if data for the site cannot be found.getExcludedIps()Returns the excluded ips of the site.
string value.Exception — if data for the site cannot be found.getExcludedQueryParameters()Returns the excluded query parameters of the site.
string value.Exception — if data for the site cannot be found.isEcommerceEnabled()Returns whether ecommerce is enabled for the site.
bool value.Exception — if data for the site cannot be found.getSearchKeywordParameters()Returns the site search keyword query parameters for the site.
string value.Exception — if data for the site cannot be found.getSearchCategoryParameters()Returns the site search category query parameters for the site.
string value.Exception — if data for the site cannot be found.isSiteSearchEnabled()Returns whether Site Search Tracking is enabled for the site.
bool value.Exception — if data for the site cannot be found.getCreatorLogin()Returns the user that created this site.
string|null —
If null, the site was created before the creation user was tracked.getIdSitesFromIdSitesString()Checks the given string for valid site IDs and returns them as an array.
It accepts the following parameter(s):
$ids (string|array) —
Comma separated idSite list, eg, '1,2,3,4' or an array of IDs, eg, array(1, 2, 3, 4).$_restrictSitesToLogin (bool|string) —
Implementation detail. Used only when running as a scheduled task.Returns: array —
An array of valid, unique integers.
clearCache()Clears the site data cache.
See also setSites() and setSitesFromArray().
clearCacheForSite()Clears the site data cache.
See also setSites() and setSitesFromArray().
It accepts the following parameter(s):
$idSiteIt does not return anything or a mixed result.
getNameFor()Returns the name of the site with the specified ID.
$idsite (int) —
The site ID.string value.getGroupFor()Returns the group of the site with the specified ID.
$idsite (int) —
The site ID.string value.getTimezoneFor()Returns the timezone of the site with the specified ID.
$idsite (int) —
The site ID.string value.getTypeFor()Returns the type of the site with the specified ID.
It accepts the following parameter(s):
$idsiteIt returns a string value.
getCreationDateFor()Returns the creation date of the site with the specified ID.
$idsite (int) —
The site ID.string value.getMainUrlFor()Returns the url for the site with the specified ID.
$idsite (int) —
The site ID.string value.isEcommerceEnabledFor()Returns whether the site with the specified ID is ecommerce enabled or not.
$idsite (int) —
The site ID.string value.isSiteSearchEnabledFor()Returns whether the site with the specified ID is Site Search enabled.
$idsite (int) —
The site ID.string value.getCurrencyFor()Returns the currency of the site with the specified ID.
$idsite (int) —
The site ID.string value.getCurrencySymbolFor()Returns the currency of the site with the specified ID.
$idsite (int) —
The site ID.string value.getExcludedIpsFor()Returns the excluded IP addresses of the site with the specified ID.
$idsite (int) —
The site ID.string value.getExcludedQueryParametersFor()Returns the excluded query parameters for the site with the specified ID.
$idsite (int) —
The site ID.string value.getCreatorLoginFor()Returns the user that created this site.
It accepts the following parameter(s):
$idsite (int) —
The site ID.Returns: string|null —
If null, the site was created before the creation user was tracked.