Intelligent Publishing
1. Introduction
This document explains how to configure intelligent publishing for Cascade. It assumes the following that you have PHP 5 and Cascade Server installed and are proficient with Cascade. It also assumes that the CMS has permission to write the directory in which you want the script to reside, and that PHP's home directory has been added to your path environment variable. As this script will usually be run from a cron daemon (Unix/Linux) or a scheduled task (Windows), we also assume one of the following is true for the machine on which the script will run:
- write access to the crontab file (Unix/Linux)
- administrator access to the machine (Windows XP/2000/2003)
2. Overview
This intelligent publishing script is designed to ensure that the most recently created/updated content on your site is published automatically on a scheduled basis. This prevents you from having to manually identify and create publish sets for frequently updated assets or folders. This is accomplished by examining an index of your site that is published on a regular basis and determining which pages and files have been modified since they were last published. The script then issues SOAP publish requests to your CMS instance.
Although we only discuss here how to set up execution of the intelligent publishing app on a daily basis, it is possible to set it up to execute at any interval you like by simply modifying the crontab entry or scheduled task.
3. Installation
Follow these steps to get the script integrated into your CMS:
- Create a folder in which the intelligent publishing script and associated items will reside - say /yoursite/ipub. You probably don't want the contents of this folder indexed to be published, so you may want to uncheck 'Include for indexing' in the system pane. Create the folder /yoursite/ipub/log, as well.
- Upload the file ipub.php to /yoursite/ipub.
- You may want to publish the contents of this directory to a location other than the web server to which your site is being published. If so, you'll need to set up a target/transport/destination specifically for this purpose. Keep in mind that the base folder of this target should be /yoursite/ipub to prevent anything else from being published here. Otherwise, it is assumed that you have set up a target/transport/destination for you site already and that you are satisfied with the location to which this will publish.
- VERY IMPORTANT - the next thing you need to do is edit ipub.php and change the values of the variables $index_file and $config_file to the FULLY QUALIFIED PATHS (filesystem paths, not CMS paths) of the index and configuration XML files as they will appear when published out (e.g., /var/www/yoursite/ipub/ipub-config.xml). This is important because neither crond nor the Windows task scheduler is going to start PHP in the directory containing our files, so the script needs to be able to find these using the absolute path. Also, keep in mind that PHP on Windows expects FORWARD SLASHES instead of the backslashes you might otherwise use.
- Create a data definition using the XML in ipub-config-data-definition.xml as the data definition XML.
- Create the page /yoursite/ipub/ipub-config (it should have ONLY a simple XML configuration - i.e. nothing but a DEFAULT region) and apply the data definition from step 5. This page's XML configuration should use a template with an XML target that publishes with a .xml extension (preferably the target you may have created in step 3).
- Edit the page and supply the appropriate values. The CMS URL should be of the form http://hostname:port. You should set up a special user for the publishing application if you want to be able to audit its actions.
- Create an index block of your site. The indexed folder should be the base folder of your site (/yoursite in our example), and you should include pages and files as indexed asset types. Also, ensure that both 'regular content' and 'system metadata' are checked for indexed asset content. The depth of the index should be an arbitrary number large enough to ensure that all levels of your site are indexed.
- Create a new stylesheet using the file site-index-filter.xslt provided below. This stylesheet minimizes the size of the site-index page by filtering out all unnecessary information in the index block.
- Create the page /yoursite/ipub/site-index and apply the above index block and XSLT to the DEFAULT region. It should use a configuration set similar to the one used in step 6.
- Create a publish set containing only the above page and set it to publish on an interval equivalent to that you intend to use for scheduling of the intelligent publishing job. Set the publish time to 30-60 minutes prior to the time you want the intelligent publishing job to execute.
- Publish the folder /yoursite/ipub to the desired destination.
- At the command line or shell prompt on the machine to which you just published, enter the following command: php -f /path/to/ipub/ipub.php (keep in mind you PHP still expects forward slashes on a Windows machine).
- Check the log folder to ensure that a log was written. If so, you have successfully set up intelligent publishing and are ready to set up scheduling.
4. Scheduling Execution
In order to schedule execution of the PHP script (at midnight daily in this case), you'll use either a cron job or a scheduled task.
IF RUNNING VIA A CRON JOB (UNIX/LINUX):
Add the following line to your crontab file:
0 0 * * * php -f /path/to/ipub.php
IF RUNNING VIA A SCHEDULED TASK (WINDOWS):
- Choose "Scheduled Tasks" from the Control Panel
- Choose "Add Scheduled Task" and click "Next"
- Click "Browse...", then browse to and select your php.exe file, click "Next"
- Give the task a name and choose an interval (usually daily), click "Next"
- Set the start time to midnight and date to today's date, click "Next"
- Enter the credentials for the user who should run the task, click "Next"
- Check the box "Open advanced properties..." and click "Finish"
- Change the "Run" field to something like: C:\php\php.exe -f C:/path/to/ipub.php
- Review the other tabs, make any necessary changes and click "OK"
All that is left is for you to check the log directory when the scheduled time rolls around and ensure that a log file is written there.
Files
- intelligent-publishing-PHP.zip
A zip of all the files you will need to set up the application using PHP. - ipub-php.txt
The intelligent publishing script. - ipub-config-data-definition.xml
The configuration page data definition - ipub-config.xml
An example configuration file - site-index.xml
An example site index XML file - site-index-filter.xslt
XSLT to filter the index block content in order to minimize the size of the index to be parsed - 11-14-2006-94928.log
An example log file

