...

View Full Version : Most Efficient Way to make a Custom Templated Site?



Bobafart
03-04-2010, 02:19 PM
Say I have a website that allows the user to select a specific template design to display the site. The user's template design preference is saved in a mySQL database (user registration required).

What is the most efficient way to display the webpage template? (ie. lowest load)



<?php
if(isset($_SESSION["userid"])){
$sql="SELECT customTemplate FROM userPrefs WHERE userid = {$_SESSION[userid]}";
$result=mysql_query($sql);
if($result){
$userTemplate = mysql_result($result,0,0);
include($userTemplate . ".php");
}
}else{
include("defaultTemplate.php");
}
?>


Is this the best way to do it? Is there another way (excluding cookies since I want to make it user registration based).

bacterozoid
03-04-2010, 02:59 PM
That seems like an OK way to me...nothing overwhelming about a SQL query.

The only thing I would do is grab all of the user settings when the user logs in...you've got to do a query anyways, so why not just grab all the settings and store them in the session the first time?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum