cTemplate Publications
When a cTemplate is processed in the context of a publication, such as during a publish or preview, Publication Variables are available and the behavior of #LINK() and #OUTPUT() can be customized.
Global Publication Variables
For information about the global publication variables, see cTemplate Global Variables.
URL Processor
If the Publication specifies a URL Processor, it will be called each time #LINK() and #OUTPUT() are called to process and potentially modify the resulting URL.
The URL Processor field in a Publication is a fully qualified (namespaced) PHP class that can be loaded by the auto-loader. For example, \com_example_www\url_processor
.
The following methods may be implemented in the class to override the default URLs produced by #LINK() and #OUTPUT().
- process_absolute($state, $shared, $path) - Return a string with the absolute URL.
- process_relative($state, $shared, $path) - Return a string with the relative URL.
- process_root($state, $shared, $path) - Return a string with the rooted URL.
Remove index.html
One URL Processor comes with webCOMAND because it is commonly used by Publications to remove the optional /index.html from the end of URLs. To utilize it:
- Open the desired Publication.
- Click the Settings tab.
- Enter the URL Processor:
\io_comand_publication\url_processors\remove_index
- Click Approve
In addition to the URL Processor, you may also want to configure the web server to redirect URLs that end with /index.html to the URL without equivalent /index.html at the end. To do this on Apache web server, add an .htaccess file to the Document Root with the following lines.
RewriteEngine on
# redirect index.html URLs to their parent root (/)
RewriteRule ^(|.*/)index\.html$ /$1 [R=301,L]