Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active September 19, 2017 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeathe/65eca0d2516ea097526650858cca0bb4 to your computer and use it in GitHub Desktop.
Save jdeathe/65eca0d2516ea097526650858cca0bb4 to your computer and use it in GitHub Desktop.
Jadu Continuum CMS - Readable URLs for Custom Scripts

Jadu Continuum CMS - Readable URLs for Custom Scripts

The recommended location for custom scripts written for the Jadu CMS platform is within /public_html/site/custom_scripts/ but this can lead to long and unfriendly URLs. Here we show how to use the Readable URLs feature to create a cleaner URL structure for a simple custom script.

Installation

  1. Create a new directory <install-path>/public_html/site/custom_scripts/php_version and populate it with the following files:
  • htaccess_readable
# custom_scripts/php_version
RewriteRule ^/?custom_app/(.*)$ /site/custom_scripts/php_version/$1 [QSA,NC,L]
RewriteRule ^/?custom_app/?$ /site/custom_scripts/php_version/index.%EXTENSION% [QSA,NC,L]
  • index.php
<?php 
print "PHP Version: " . phpversion();
  1. Add the following element to <install-path>/config/readable_urls.xml
<custom_scripts_php_version><config:constant name="MAIN_HOME_DIR" />public_html/site/custom_scripts/php_version/htaccess_readable</custom_scripts_php_version>

It should end up looking something like this

<?xml version="1.0" encoding="utf-8" ?>
<readable_urls xmlns:config="http://www.jadu.co.uk/schema/config">
  <core><config:constant name="MAIN_HOME_DIR" />jadu/htaccess_readable</core>
  <custom_scripts_php_version><config:constant name="MAIN_HOME_DIR" />public_html/site/custom_scripts/php_version/htaccess_readable</custom_scripts_php_version>
</readable_urls>
  1. Configuration data stored in the XML files is cached so we must remove the cache file to allow the update in step 2 to take effect. To do this from the Control Centre use the Cache Bash maintenance script - navigate to /jadu/maintenance/cacheBash.php check "Config Cache" and click "Delete Selected".

  2. Toggle the Readable URL feature to force the .htaccess file to be rebuilt.

  3. This demo script should now be accessible from http://<install-domain>/custom_app where <install-domain> is the domain name of your development environment for example http://jadu-cms.local/custom_app and, if all went well you should see the version number of PHP that's installed.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment