Docs: Examples of Extensions
Show AllHide All
-
Main Page
- About
-
About
- Development
-
Code Library
Databases
- Extensions
-
Examples
Snippets
Redirects
Custom head
Introduction
- Templates
-
Skins
Smart Tags
Body Tag Classes
Master Template
- Variables
-
Language
Session Variables
Page Variables
add page
Last update: Databases
by Sean on Tuesday 12th of July
at 04:05pm
example 1: page redirection
In this example someone has linked to your website with an incorrect or obsolete URL: www.yourwebsite.co.nz/homepage
While there are other ways you can set redirects, you can edit your top.inc file and set up a simple redirect:
<?
if($_SERVER['REQUEST_URI']=='/homepage') {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: /" );
exit;
}
?>
example 2: custom text
You can use the $_PAGE['custom_text'] variable to display text on any page below the h1 tag. In this example we can use the $_PAGE['custom_text'] variable to display a message on the cart page:
<?
if($_PAGE['page']=='order'){
$_PAGE['custom_text'] = "<p>When you are ready to pay for your order click the <a href=\"/checkout/\">checkout</a> button.</p>";
}
?>
example 3: creating a snippet
In this example we create a Snippet to insert into the footer.html file of the template. This snippet will display the appropriate phone number prefix depending on the session country code of the person viewing the page (New Zealand country code is '121').
In the top.inc file we insert:
<?
if($_SESSION['country_id']=='121') $snippet1 = '(09)'; else $snippet1 = '0064 9';
?>
in our template/footer.html file we add:
<div class="contact_number">For help please phone us on {$SNIPPET1} 555 2528</div>
Revisions history (20) ( hide | show ) Extensions > Examples of Extensions