Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 10-19-2010, 04:39 AM   #1
Registered: Nov 2008
Posts: 44

Rep: Reputation: 15
PHP Templating

Hi, i'm working on a small CMS project. When starting out I didn't know too much CSS, so virtually everything was wrapped in HTML and a little CSS. The main page templates used the following functions:

function theme_stylise($data,$tpl='node')
	global $theme_blocks;
	return theme_evaluate($theme_blocks[$tpl],$data);

function theme_evaluate($s,$data=array())
	global $page;
	return $l;


$theme_blocks['login_user']="<div class='login_user'><?php print \$data['content']; ?></div>";

$theme_blocks['profile_menu']="<div class='profile_menu'><?php print ' | '; foreach(\$data['menu'] as \$e){ print \$e.' | ';} ?></div>";

Further down the line I also added the following:



function shop_templates($ref,$type=0)
		<h2>Order Reference:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_ORDER_REF_</h2><br />
		<h2>Order Details</h2><table><tr class='tr_pch'><td><b>Status</b></td><td><b>Order Ref</b></td><td><b>Date</b></td><td><b>Total Cost</b></td></tr>
		<tr><td colspan='99'><hr /></td></tr>
		<tr class='tr_pc1'><td>_ORDER_STATUS__ORDER_RESEND_</td><td>_ORDER_REF_</td><td>_ORDER_DATE_</td><td>_ORDER_TOTAL_</td></tr>
		<tr><td colspan='99'><hr /></td></tr>
		<br /><br />
		<h2>Order Items</h2>
		<tr class='tr_pch'><td><b>Status</b></td><td><b>Title</b></td><td><b>Ref</b></td><td><b>Qty.</b></td><td><b>Items Cost</b></td><td><b>Shipping</b></td><td><b>Total</b></td></tr>
		<tr><td colspan='99'><hr /></td></tr>
		<!--<tr><td colspan='99'><br /><hr /><br /></td></tr>-->
		</table><br />
		return array(array("_ORDER_STATUS_","_ORDER_RESEND_","_ORDER_REF_","_ORDER_DATE_","_ORDER_TOTAL_","_INVOICE_ITEMS_"),$s);
		$s="<tr class='_ODD_'><td>_STATUS_</td><td>_ITEM_TITLE_</td><td>_ITEM_REF_</td><td>_QTY_</td><td>_ITEM_COST_</td><td>_SHIP_TITLE_ _SHIP_COST_</td><td>_TOTAL_</td></tr>\n";
		$s.="<tr class='_ODD_'><td colspan='7'>_DROPBOX_</td></tr>\n";
		$s.="<tr><td colspan='7'><hr /></td></tr>\n";
		return array(array("_ODD_","_STATUS_","_ITEM_TITLE_","_ITEM_REF_","_QTY_","_ITEM_COST_","_SHIP_TITLE_","_SHIP_COST_","_TOTAL_","_DROPBOX_"),$s);
		$s="<div class='shop_size_item'>_SIZE_RADIO_ _SIZE_TITLE_ : _SIZE_COST_ - _SIZE_DESC_</div>";
		return array(array("_SIZE_RADIO_","_SIZE_TITLE_","_SIZE_DESC_","_SIZE_COST_"),$s);
	return null;

Now most small page parts use the second method, and are then grouped together by the first method.

After implementing the second method in a single module I realised that it was being called quite a bit.

So before updating the rest of the CMS with this method I'd like to hear your views on efficiency, templating, either using either of the above methods, or any more you may suggest.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04) LXer Syndicated Linux News 0 06-14-2010 11:42 PM
LXer: Smarty templating and presentation library for PHP LXer Syndicated Linux News 0 12-09-2005 05:53 PM
LXer: Smarty templating and presentation library for PHP LXer Syndicated Linux News 0 12-09-2005 02:36 PM
Creating a PHP templating system - any ideas? vharishankar Programming 1 07-06-2005 10:51 PM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM

All times are GMT -5. The time now is 07:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration