SETTING UP A SIMPLE WEBSITE
---------------------------
Valid for Version: 0.2
Last Revised: 2004-06-30
Contents
--------
1. Get sample website
2. Install `kickstarter.php'
3. Make `cache' and `compiled' dir writable
4. Add pages to `pages.xml'
5. Add menu items to `menus.xml'
6. Browse
7. Playing with templates
8. Playing with contents
9. Basic execution flow
10. Further information
1. Get sample website
---------------------
Get the mwlib-m.m-sample-website.tar.gz tarball on my homepage ( http://studer.tv ).
% cd /path/to/your/webroot
% cp /path/to/downloaded/mwlib-m.m-sample-website.tar.gz .
% tar xzf mwlib-m.m-sample-website.tar.gz
You should now have a very basic website. Use
% ls
and
% cd folder
to explore the folder structure.
2. Install `kickstarter.php'
----------------------------
The `kickstarter.php' file is the gateway file to your mwlib web pages. Every request of a http client is handled by `kickstarter.php'.
Open `kickstarter.php' with you favourite text editor and look at the php code. Basically it's doing the following:
- including mwlib
- creating the framework
- opening and executing the main template
- shutting down the framework
If every request is handled by 'kickstarter.php', how does it now which page to show?
There are two possibilities to tell 'kickstarter.php' which page to show.
Case 1: Using request rewrite techniques (mod_rewrite)
-------
This is the preferred way to tell kickstarter.php which page to load as
it does not clutter your website's directory with 'unnecessary' files.
Configure your HTTP server in such a way that it rewrites each request
to load `kickstarter.php' and pass the unique page_id by a GET-Parameter.
Example excerpt for `.htaccess' or `httpd.conf' file for Apache:
RewriteEngine On
RewriteRule ^(.*)\.page$ kickstarter.php?page_id=$1 [L,QSA]
Case 2: Using 'shadow PHP files'
-------
This possibility does not require any HTTP server configuration. But it
requires one small PHP file for each web page browsable by a HTTP client.
This file only specifies the page_id and then includes the kickstarter.php.
Example file somepage.php:
3. Make `cache' and `compiled' dir writable
-------------------------------------------
mwlib caches some information inside the mwlocal/cache directory. Compiled templates are stored inside mwlocal/compiled. Thus, those two directories must be writable by the webserver user (normally `apache').
Type the following commands to make them writable (make sure the working directory is where you've installed the sample website):
% chmod a+w mwlocal/cache mwlocal/compiled
TODO: check, whether this is a security risk. I think, it is :-/
4. Add pages to `pages.xml'
---------------------------
Every page that can be accessed by a user must be listed in the `pages.xml' file. You also specify the standard template and templates for certain pages in there.
Pages may be associated with menu entries if you're using the menu module.
Note that the framework expects the `pages.xml' file to be on top level of a site.
Open the file with the file with your favourite text editor and read the xml comments.
5. Add menu items to `menus.xml'
--------------------------------
The `menus.xml' holds the structure for the menu module that displays navigation menus for every page. Every menu entry has a unique ID which the page defined in `pages.xml' refers to.
The menu module expects the `menus.xml' file to be on top level of the site.
Open the file with the file with your favourite text editor and read the xml comments.
6. Browse
---------
Point your browser to the server where you've set up the sample website. Check if everything works as expected.
If you see a "404 - Page Not Found" message, ensure that all requests are re-pointed (either by "shadow" php files or by mod_rewrite) to the `kickstarter.php' file (point 2).
If there are error messages at the bottom of the page telling you that something could not have been saved, check point 3 again and make sure those directories are writable by the web server process.
If you see error messages about `pages.xml' or `menus.xml', make sure they are valid xml. Check for proper tag nesting and special chars.
7. Playing with templates
-------------------------
Open the `pages.xml' file again and look at the first