Note that the Paloose system is a subset of Cocoon so almost all of the features in Paloose are directly derived from Cocoon so it is useful but not essential to know about Cocoon. In order to see how it works let us build that archetypal beginner's site: "Hello World".
Create a base folder to hold your site where your Apache server will see it. In this case we will create a folder 'HelloWorld' in the root directory that we created during the install.
Create the folders 'resources/transforms' and 'resources/syles'.
Create a 'content/page.xml' file which is the content of the page. Note that there is no style information here at all — we are only describing what the individual parts of the page are. The file should contain the following XML code:
Now we need a transformation to take that and turn it into something that the browser will understand. Create a file 'resources/transforms/page2html.xsl' containing the following:
This is a fairly crude transformation and real ones will be considerably more complex that this.
Note that the code that this produces is based on divs. The final style is not put in until we add a style file. So create a file:
It is worth noting here that we have three separate (and hopefully orthogonal) files that make up our simple site. The content (heading and paras), the layout structure (text blocks) and the layout style (fonts, colours etc). All should be able to be manipulated with minimal interference with each other.
We need to tie them all together so that a request for http://hostname/HelloWorld/page.html will produce the page that we require. The control of this is within the sitemap.xmap file. It follows standard Cocoon practice with only minor differences in the component definitions. First of all we define the components that we are going to use. Note that to those wo are more used to Cocoon the 'src' attribute normally defines a Java package, in Paloose it is the name of a PHP file. So paloose://lib/generation/FileGenerator' defines a file '${ROOT_DIR}/paloose/lib/generation/FileGenerator.php'. This means that you can define your own components fairly easily and place them where you want (there is an example component given in the distribution).
The components that are defined above are the default ones and support almost all of what you might require. The HTML serializer needs some more work but the current version should suffice most people's needs at present. Next we use these components to build pipelines (in the same fashion as Cocoon) to handle requests.
Having done the sitemap we must now tell the Apache server what to do to use Paloose. This is done using the .htaccess file (note the leading period in the name). The key is to use the Rewrite facility of the Apache server. So place the .htaccess file in the home directory of your site with the following:
This tells Apache that all requests for files in the HelloWorld directory (in which the .htaccess file sits) should obey the rule above. So a request for 'http://host-name/HelloWorld/page.html' would be translated to 'http://host-name/HelloWorld/paloose.php?url=page.html'.
If you see the following error (or similar)
when you try and run the simple site, it is almost certain that you are running PHP4. You will need to speak to your ISP to find out how to direct all Paloose code to use PHP5 (assuming that they have this as an option).
The final part of the puzzle is what to do with the rewritten request above. We need a file paloose.php in the HelloWorld folder. This contains all the necessary user defined information and the link to start Paloose running. There is an example file in the Paloose distribution to help you get started in ${ROOT_DIR}/paloose/resources/templates/paloose.php.dist.
The interesting parts of the paloose.php file that you may want to change, are detailed below. Change the PALOOSE_DIRECTORY address here to indicate where you have put the main Paloose folder. It can be relative to your application site folder.
The next lines define where the main log4php logger configuration file is kept. You can use pseudo-protocols here. You also define the path to the Log4PHP distribution (LOG4PHP_DIR). This is a change since version 1.1.2b1. If you are using versions earlier than this then the logging library is included within Paloose and this line (LOG4PHP_DIR) is not necessary.
Normally should not have to change the root sitemap if you use the standard Cocoon names. The directory is always the top level user directory.
The error page to give back for User errors (errors in sitemap etc). If you override these to your area make sure that you use an absolute directory path — you can use the 'context' pseudo-protocol here.
Be careful of the path here — although it is relative it looks as an absolute one. It is in fact relative to the Apache root document directory. Must always have a leading path separator.
The file that contains the index for each level of the gallery. For this simple example it can be ignored. Indeed 99% of the time it could be left as this. The ImageMagick bin path is rarely needed if your server has the various binaries of the ImageMagick package on the Path. It is commented out in the paloose.php.dist file.
The error page to return to the user for internal programming errors. These should not need to be overridden unless you want to use your own.
Again, be careful of the path here — it is relative to the Apache root document directory. Must always have a leading path separator.
Last remaining thing is to open a browser and go to the address http://[host-name]/HelloWorld/page.html. If all is well you should see the following