Sometimes you may have processing that you would like to perform at the beginning of each page load. This can be done by entering a startup class within site_settings. Normally this class will be stored within the site's classes folder.
Here we see an example of a startup class definition.
Notice that you will normally define a site object as a class variable and this must have a simple set method generated. This method will be called automatically to pass the main site object to the class.
The class must define a method called setup. This will be called during the page load process.
Let's review what is happening in the sample code.
This same site is hosted at two different domains, one with a .com extension and one with a .ca extension. First we call the $site function programmatically to request the top level domain.
Next we use the tld to set the English locale to either CA or US. This will be used by the $locale references used on the site. For example, we can render the word color on the .com site and colour on the .ca site. We also add the locale to the html lang property.
Next we make sure that the codeframe that is loaded includes a linktags object. For example, this same request could be used to generate email content which does not generally define linktags.
The remainder of the code is used to set the correct Google Analytics key, depending on the URL as well as cause the following link alternate tags to be generated:
This is a good example of how you can: