Redirection/Wrapping Issues
Friday, April 25th, 2008- How does the redirection work?
To make the redirection work you’ll need the .htaccess file included in the archive and upload it at the root of your domain name along with the index.php file. Both need to be present for the redirection to work.
- How does the “index.php” file in the root works?
The index.php handles all the redirection after the request passes from the .htaccess file. Based on the URL the sctipt will find the section name and the parent section name (if any) and submit that information to the “template/index.php” which resources the actual data. Note that the script can only handle pages created though the template engine’s administration interface. If the engine doesn’t find a section assigned to that request it will redirect the visitor to the index page.
- What is the .htaccess commands mean?
This is the code included in the .htaccess file
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
Basically it says that if a file or directory from the URL requested is not actually there then redirect to the index.php on the same level to handle the request. It’s the same code that Wordpress uses for its search engine friendly URLs…
- I can’t get the redirection to work! I’m only seeing the index page.
Make sure that mod_rewrite is loaded for your server setup. That’s the module the .htaccess file uses for the redirection commands. Go to where your Apache is installed and move to the “conf/” sub-folder. Open “httpd.conf” in a text editor.
Find the line
LoadModule rewrite_module modules/mod_rewrite.so
and make sure it’s uncommented (no # in front of it). Save the file. Re-start Apache. Now redirections should work.
- What information does the engine need for a redirection?
All information is passed through the URL, the section name and it’s parents in an hierarchical order. It will then compile all the right pieces and present the template automatically.
- Can I load the template manually?
To load a template from your script all you need to know is the section slug you have created in Template Blocks for that script. Then load it in the variable $GLOBALS[’section’] and include the ‘/template/index.php’ file. Now you have the template in two variables:
$GLOBALS[’template-pre’] - the template before the content
$GLOBALS[’template-post’] - the template after the content
It’s up to you to use the template however you want in your script.
- The variable $GLOBALS[’section’] is reserved by my script. What do I do?
In this case you can easily change it to anything else you want. Simply open “template/index.php” and replace the $GLOBALS[’section’] to $GLOBALS[’anything_you_want’]. Then assign to that variable the name of the slug for the section that is linked with the script.