Latest Websites

Promotions and Events

Take information gathered using the facebook OpenGraph API and make something of it. I thought if I kept my brief short, I would have a simple and short project,...>>read more.

Name Your Domain

Web Hosting, one hot topic in my life and search engine optimisation the other together they led me to register a targeted domain name to sell co.za registrations.read more.

Web Tutorials Website

I've always typed so many notes and short reminders for myself in good old NotePad, so that when I need a refresher I can quickly browse through them and stir up the old...>>read more.

My Blog

Web Design Strip

BlackBerry

Where to begin when I have so much to talk about, I have recently won a BlackBerry 9860torch, my first smartphone. I'm now thinking of developing.....
read more.

WHMCS Smarty

It's a new year, one that will bring bigger and better things my way is the hope. So my website has been doing very well with certain keywords,.....
read more.

Tutorials Index

  1. 2

  2. Smarty Functions

    1. This URL Smarty Function
  3. Smarty Pagination Plugin

    1. Pagination Class
    2. Smarty Pager Function
  4. Build a scalable website/weblog/cms

    1. Getting Started
    2. Build the Foundations
    3. Dynamic SEO Friendly URL
    4. PHP Helper Classes

Tutorials Intro

These tutorials reflect personal projects while practicing of new tools, ideas, techniques and technologies. They can not be used on their own as a final solution for any website.

I will be using xHTML, CSS and PHP in most of the tutorials so a basic understanding of each will be ideal but not a requirement if you work each tutorial from the beginning. I will also be making use of the jQuery javascript API for effects, AJAX and loads more.

My personal favourite has got to be the versatile and highly scalable php Smarty Template Engine, so almost everything I build uses it. I'm not on my own in working with and trusting the smarty template engine, there are loads of large names out there using it, Jamroom, XOOPS CMS, Movable Type, WHMCS, Serendipity, CMS Drupal to name a few, go to Smarty's Resources page for more.

This URL Smarty Function


Tutorial:  Smarty Functions

Skills:     php, smarty

Goal:      To output the URL in browser window

Whilst I was trying to find the answer to my question "How to display the URL in the browser window on the page using smarty?" I couldn't find an answer, "See a need, fill a need." thanks Mr Bigweld. Simply create a file named function.thisUrl.php in your smarty plugins folder and copy and paste this code, save and upload.
Within your smarty template file you can now output this pages url as {thisUrl}, simple.

/includes/Smarty/plugins/function.thisUrl.php
<?
function smarty_function_thisUrl ($params, &$smarty){
$thisUrl = 'http';
if ($_SERVER["HTTPS"] == "on") {$thisUrl .= "s";}
$thisUrl .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$thisUrl .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$thisUrl .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $thisUrl;
}
?>