View Single Post
Old 10-11-2007, 05:54 PM  
TheDoc
Too lazy to set a custom title
 
TheDoc's Avatar
 
Industry Role:
Join Date: Jul 2001
Location: Currently Incognito
Posts: 13,827
You use smarty plugins. This allows you to create blocks of php that can do different functions, then call those functions to the template.

Often in /smarty/libs/plugins

You normally don't have to mysql connect directly when using a plugin, but you can if you want to connect to a different db other than the local setup. As an example

Code:
function smarty_function_getpassword($params, &$smarty)
{
	$user = $_SERVER[PHP_AUTH_USER];
	$result = mysql_query("SELECT * FROM members WHERE username = '$user'");

   $password=$row["pass"];
   $smarty->assign ($params['xpassword'], $password);
   return ($password);
}


Call it like: {getpassword values="xpassword"}
__________________
~TheDoc - ICQ7765825
It's all disambiguation
TheDoc is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote