Latest Websites

Young Modz

The Young Modz club is a non-profit organization that takes part in regular competitive and fun events, organized by a small committee. The club was started in the...>>read more.

Events Calendar Class

This calendar class was written as part of a project involving a clubs events, it highly customisable and simple to implement.read more.

Skallabrak

Skallabrak, a South African rock band, where looking for a site that they could keep their fans updated with coming gigs and events, a discography and a news platform.read more.

My Blog

Web Design Strip

Smarty Development

Quiet must mean busy? Well in my case this has been the situation, I've secured another sponsorship to a restuarant in Tulbagh, read more.

Smarty Development

If March is anything like February was, bring it on!! Feb2011 has got my year up to a running start and I am certain that 2011 is definately this.....
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.


Smarty Pager Function


Tutorial:  Smarty Pagination Plugin

Skills:     smarty, php, html

Goal:      Write smarty function plugin

Starting off you will need to create 5x .tpl files in the templates folder.

  • /templates/pager_previous.tpl
  • /templates/pager_next.tpl
  • /templates/pager_middle.tpl
  • /templates/pager_first.tpl
  • /templates/pager_last.tpl

You will need to create the smarty function under the smarty plugins folder.

/includes/Smarty/plugins/function.pager.php
<php
function smarty_function_pager($params, &$smarty) {

if (!class_exists('Page')) {
$smarty->trigger_error("pager: missing Page.class.php");
return;
}
$page = new Page($params['mode'],$params['currentpage'],$params['perPage'],$params['range'],$params['navSet'],$params['thisTpl']);
foreach($params as $k=>$v){
$smarty->assign($k,$v);
}
$smarty->assign('page',$page->pageInfo);
$smarty->assign('navSet',$page->link);
$smarty->assign('pagerNext',$page->pagerNext);
$smarty->assign('pagerPrevious',$page->pagerPrevious);
$smarty->assign('pagerMid',$page->pagerMid);
$smarty->assign('pagerFirst',$page->pagerFirst);
$smarty->assign('pagerLast',$page->pagerLast);

$section = $smarty->fetch($params['tpl'].'.tpl');
return stripslashes($section);
}
?>