|Classes of Barton Phillips||>||PHP Site Class||>||docs/files.md||>||Download|
Additional Files User by SiteClass
The 'mysitemap.json' File
The 'mysitemap.json' file is the site configuration file. 'siteload.php' loads the 'mysitemap.json' file that is in the current directory. If a 'mysitemap.json' file is not found in the current directory the parent directory is searched and this continues up until the DocuementRoot is searched and if still not found an exception is thrown.
Once a 'mysitemap.json' file is found the information in it is read in via 'file_get_contents()'. The information from the 'mysitemap.json' file is converted into a PHP object and returned.
You can generate a 'mysitemap.json' file by running 'mysitemap.json.php' and redirecting the output to 'mysitemap.json'.
My usual directory structure starts under a 'www' subdirectory. On an Apache2 host the structure looks like this:
If I have multiple virtual hosts they are all off the '/var/www' directory instead of a single 'html' directory.
How the xxxFile files look
In the 'mysitemap.json' file there can be three elements that describe the location of special files. These files are 1) 'headFile', 2) 'bannerFile' and 3) 'footerFile'.
I put the three special file in my '/var/www/html/includes' directory (where 'html' may be one of your virtual hosts and not named 'html').
Here is an example of my 'headFile':
These 'xxxFile' files return their contents. The $arg array is created form the argument passed to the 'getPageTopBottom' method. The 'getPageTopBottom' method also has access to the SiteClass '$this' property.
You will see if you delve into the SiteClass code that many things can be passed to the getPageTopBottom method, and the various sub-methods, but the standard things are:
As you saw in example 5 (example5.php in the 'examples' directory) I passed a '$h' object to
As you can see in the 'headFile' example the '$this' can also be used as in '$this->copyright'. Any of the public, protected or private '$this' properties can be used in any of the special files as they are all included within 'SiteClass.class.php'.
As these special files are PHP files you can do anything else that you need to, including database queries. Just remember that you need to use '$this'. For example, to do a query do
I usually call these files 'head.i.php', 'banner.i.php' and 'footer.i.php' but you can name them anything you like. In the 'mysitemap.json' just add the full path to the file. For example:
There is a default for the head, banner and footer section if you do not have special files. The DOCTYPE is by default
Creating the special files make the tedious boiler plate simple and yet configureable via the $arg array.