Lesson 8.2: Siteaccess settings
A siteaccess is a set of settings chosen for a request: the public site, the administration, the editor, a second language. For developers it answers two questions: which siteaccess is running, and where a setting should be written so it applies to the right ones. This lesson covers both; the Multisite and site packages course goes deep into matching and several sites.
At a glance
| Course | Developers |
| Module | Module 8: Settings and siteaccesses |
| Duration | 45 minutes (15 presenting, 30 exercise) |
| Level | Intermediate |
| Audience | Developers |
| Prerequisites | Lesson 8.1 |
Learning objectives
After this lesson, learners can:
- list the siteaccesses of an installation and the folder that holds each one's settings;
- read
MatchOrderand the matching settings that choose a siteaccess for a request; - run a command for a given siteaccess with
-s <siteaccess>; - compare one setting between two siteaccesses with
exp:ini where; - decide whether a setting belongs in the global override, a siteaccess folder or an extension.
Trainer's notes
How to present it
Sources: settings/site.ini [SiteAccessSettings],
What a siteaccess is
(Multisite and site packages course) and
Siteaccess host and language matching.
What it is (3 minutes). A siteaccess is a folder
settings/siteaccess/<name>/with settings for one way into the installation, listed in[SiteAccessSettings] AvailableSiteAccessList[].Matching (4 minutes).
MatchOrder=uri;host;portby default: the first part of the path, the host name, the port.URIMatchType=elementwithURIMatchElement=1takes the first path element (/admin/...). An installation fromexp:installuses path matching by default.Related siteaccesses (2 minutes).
RelatedSiteAccessList[]names the siteaccesses that share one content database, for example a site, its administration and its editor.Commands (2 minutes). Scripts and
exp:inirun for a siteaccess:-s <sa>, or the second argument ofexp:ini where.Where a setting belongs (4 minutes).
The setting is for Write it in Every siteaccess, this machine only global(settings/override/)One siteaccess, this machine only siteaccess:<sa>Every installation of your extension extension:<ext>One siteaccess of every installation of your extension extension:<ext>:siteaccess:<sa>
Common questions
Which siteaccess is a page served by? The debug output names it; exp:ini where ... <sa> shows its settings.
Can an extension be active for one siteaccess only? Yes, with ActiveAccessExtensions[] in that siteaccess's
site.ini.append.php (lesson 7.3).
What is the admin siteaccess's design? Its own [DesignSettings] SiteDesign, usually admin4 on new
installations.
Pitfalls
- Settings for a site written to the global override. They then apply to the administration too.
- A new siteaccess folder that is not listed. A folder without an entry in
AvailableSiteAccessList[]is never chosen. - Testing with the wrong siteaccess. A script without
-sruns with the default siteaccess, which may not be the one you changed.
Hands-on exercise
On the development installation.
- List the siteaccess folders:
ls settings/siteaccess/. - List the available siteaccesses in effect:
php bin/php/console exp:ini get site.ini/SiteAccessSettings/AvailableSiteAccessList. - Read the matching:
php bin/php/console exp:ini where site.ini/SiteAccessSettings/MatchOrder. - List the scopes your installation offers:
php bin/php/console exp:ini scopes. - Compare the design of two siteaccesses:
php bin/php/console exp:ini where site.ini/DesignSettings/SiteDesign <sa>and the same withadmin. - Run the playground for two siteaccesses and compare a link: add
{'content/view/full/2'|ezurl}toplay.tpland runphp bin/php/ezexec.php -s <sa> extension/mysite_hello/scripts/play.php, then with-s admin. - For each of these settings, write the scope you would choose: the site's name, debug output on your laptop, your extension's operator registration, a template override for the public site only.
- Check your answers with the table of the trainer's notes.
Expected result
- Step 2: the siteaccess names, for example
site,adminandeditoron anexp:installinstallation. - Step 3:
MatchOrderwith its value in effect. - Step 5: different designs, for example the site design and
admin4. - Step 6: the links differ in their siteaccess part when matching is by path.
- Step 7: siteaccess (or an extension's siteaccess scope), global,
extension:mysite_hello,extension:mysite_hello:siteaccess:<sa>. - The trainer discusses step 7 with the group.
Quiz
- Which setting lists the siteaccesses an installation may choose?
- What is the default
MatchOrder? A.host;uri;portB.uri;host;portC.port;host;uriD.uri - How do you run a script for the siteaccess
admin? - In which scope does a template override for the public site of every installation of your extension belong?
- Why is the global override a poor place for settings of the public site only?
Answers
[SiteAccessSettings] AvailableSiteAccessList[].- B.
uri;host;port, insettings/site.ini. - With
-s admin, for examplephp bin/php/ezexec.php -s admin <script>. extension:<ext>:siteaccess:<sa>, the extension'ssettings/siteaccess/<sa>/.- It applies to every siteaccess, the administration and the editor included.
Further reading
- What a siteaccess is: the Multisite and site packages course.
- Siteaccess host and language matching.
- Multi-site INI overrides: per-site settings inside extensions.
Related pages
- Module 8: Settings and siteaccesses
- Developers: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.