

How to add new pages to Pixaria
If you would like to add new, custom pages to your Pixaria website to provide contact details, FAQs or terms and conditions, the process is quite simple. In this example we will create a new page for frequently asked questions (FAQ).
Step 1 - Create a PHP script for your page
If you're not already using a custom theme with your Pixaria installation, you can create a customised theme by making a duplicate of the 'Advance' theme that comes with Pixaria and renaming the directory to a theme name of your choice (the name mustn't include spaces).
The first thing to do once you are working on a custom theme is to create a new text file in a text editor of your choice such as BBEdit or DreamWeaver and paste in this code:
<?php
// Set the include path for files used in this script
ini_set("include_path","resources/includes/");
// Load in the Pixaria settings and includes
include ("pixaria.Initialise.php");
// Send HTTP header and don't cache
pix_http_headers("html","");
// Go to login page if the default action for logged out users
// is to require logging in or registering before viewing content
pix_login_redirect();
// Initialise the smarty object
$smarty = new Smarty_Pixaria;
// Set the page title for the FAQ page
$smarty->assign("page_title","My FAQ Page");
// Load the template for the FAQ page
$smarty->pixDisplay('index.faq.tpl');
?>
If you want to set a title to display in the top of your web browser window, you can enter one between the quote marks in the page_title assign method.
At the bottom of the code sample, you will see a reference to the template we are going to use for this page which is loaded by a method of the Smarty class called pixDisplay(). You should change the parameter for this method to the name of the template you want to display which in this case will be 'index.faq.tpl'.
Now save this file with a .php extension in the document root of your Pixaria installation. In this example, we will assume that the new page is called index.faq.php.
Step 2 - Create the template for your new page
You now need to create a new template file with the same name that you entered into the pixDisplay function in the index.php file. To do this, create a new text file in your text editor and save it into the 'templates' directory in the new theme folder you created in step one. In this example, the text file will be saved with the name 'index.faq.tpl'.
With the text file still open, past the following code into the file and then save the changes:
<!-- INCLUDE THE TOP HTML TEMPLATE -->
{include_template file="index.layout/main.header.tpl"}
(this is where you put the contents of your page as HTML)
<!-- INCLUDE THE BOTTOM HTML TEMPLATE -->
{include_template file="index.layout/main.footer.tpl"}
Step 3 - Add your new page to the navigation
To add your new page to the navigation, you need to open the file main.header.tpl which you will find in the same location as the file you created in step two.
Don't make too many additions to the navigation or it may not fit on all browser windows
Once you've opened the file, you will see the HTML for an unordered list <ul> with entries for each navigation item in the site menu situated between <li> and </li> tags.
To add your new item, paste the code below into the position in the list where you would like your link to appear in the menu:
<li><a href="{$base_url}index.faq.php?phpMyAdmin=LNRX%2CV9w1iOO-A3431efXJH3Hc5" class="navigation-link">FAQ</a></li>
Note here that we have added the name of the PHP script we made in step one and also the name of the new page as we would like it to appear in the navigation menu.
Once you have saved the changes, you can upload your new files to the server and view the results.
Tips and troubleshooting
If you've made a custom theme for the first time, you will need to upload the entire theme directory to Pixaria and then choose it as your selected theme from the appearance control panel.
If you're using Smarty's template caching to improve the performance of your site, be sure to flush the template cache to see your changes.
On Windows you may need to configure Windows to open .tpl files in the text editor of your choice. You can do this using the folder options menu in Windows Explorer.
Created: Thursday, May 3, 2007
Last edited: Sunday, June 1, 2008
Tools & Utilities
Third Party Resources
|
Random Tips & Tricks
#4 Protect your images Make sure your images are safe from download by the wrong people by preventing unauthorised access to the library and incoming image directories. |