How to get authors e-mail (News)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
korpirkor
Forum Members
Forum Members
Posts: 100
Joined: Sun Oct 28, 2007 1:15 pm

How to get authors e-mail (News)

Post by korpirkor »

1. Create new User Defined Tag called author_email

Code: Select all

global $author_email, $gCms;

$smarty =& $gCms->GetSmarty();
$db =& $gCms->GetDb();
$config =& $gCms->GetConfig();

$id = $params['username'];
$def = $params['default'];


if(!empty($id))
{
	if(!isset($author_email[$id]))
	{
		$query = 'SELECT email FROM `'.$config["db_prefix"].'users` WHERE username LIKE "'.$id.'" LIMIT 1';
		$dbresult = $db->Execute($query);
		if($dbresult)
		{
			$row = $dbresult->FetchRow();
			$author_email[$id] = $row['email'];
		}
		else
			$author_email[$id] = $def;
	}
	
	if( isset($params['assign']) )
	{
		$smarty->assign($params['assign'], $author_email[$id]);
		return;
	}

	echo $author_email[$id];
}
2. In news template:

Code: Select all

Author <a href="mailto:{author_email username=$entry->author default="default@address.com"}">{$entry->authorname}</a>
-- edited: 29.09.2009 --
Last edited by korpirkor on Tue Sep 29, 2009 12:12 am, edited 1 time in total.
[url=http://www.polishwebdesign.pl/]Polish WebDesign Cezary Nowak
Projektowanie stron WWW[/ur]
Post Reply

Return to “Tips and Tricks”