Forums / Cotonti / Core Labs / MVC in comments

ez
#22854 2010-02-12 16:54
Hi There,

functions.php::sed_build_comments()

	$res = '<a href="' . $url . '#comments" class="comments_link"><img src="skins/' . $usr['skin']
		. '/img/system/icon-comment.gif" alt="" />';

I think this should be in a TPL, not hardcoded...
Please remove it from the low level functions...

thnx,
Leo

p.s. What a monster function is this one...

If I only want to show a picture and a comment count, this sed_build_comments() is overkill.
e.g. In the news plugin (we could use a lighter function for just getting a count.

And the function below is Lightweight and also TPL friendly (this is just an idea)

function sed_get_comments_count($code)
{
	global $db_com, $cfg, $usr;
	list($usr['auth_read_com'], $usr['auth_write_com'], $usr['isadmin_com']) = sed_auth('comments', 'a');
	sed_block($usr['auth_read_com']);
	if ($cfg['disable_comments'] || !$usr['auth_read_com']) return ("");
	$ret="";
	if ($cfg['countcomments'])
	{
		if (isset($totalitems)) $nbcomment = $totalitems;
		else $nbcomment = sed_sql_result(sed_sql_query("SELECT COUNT(*) FROM $db_com where com_code='$code'"), 0, 0);
		$ret = (string)$nbcomment;
	}

	return($ret);
}


Added 1 hour 4 minutes later:

I have made this for the NEWS plugin on a test site, and it works like a charm.. also
this is more MVC, because I can do everything in the TPL's.

And I think the speed is better (must test this somewhat further)

Hope you all think about implementing this.... :)
==- I say: Keep it EZ -==
This post was edited by ez (2010-02-12 18:27, 14 years ago)