Forums / Cotonti / Core Labs / MVC in comments

ez
#1 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 -==

Dit bericht is bewerkt door ez (2010-02-12 18:27, 14 jaren ago)
Trustmaster
#2 2010-02-12 20:21
Icons are moved to customizable resource files in Siena.

Yes, current coments/ratings is rubbish. In Siena we are going to make them plugins, with TPL files.
May the Source be with you!
ez
#3 2010-02-12 20:29
Can I make a suggestion for the resources.... Use CSS Sprites for icon thingies !
I am working on that right now.. (That's how i came to the hardcoded comments link :( )

It reduces the number off request to the server !! (And thats a good thing)
==- I say: Keep it EZ -==
Trustmaster
#4 2010-02-12 23:13
Sprites are quite hard to maintain, especially for non-designers.
May the Source be with you!
ez
#5 2010-02-13 02:51
I have been playing with sprites for a few days now, there are a few good articles about it.
BUT, you are right, you have to know how those Sprites work.
Still it improves performance.

Here are some documents (for the interested)

Articles:
http://www.alistapart.com/articles/sprites/
http://www.websiteoptimization.com/speed/tweak/css-sprites/

General website optimizing:
http://developer.yahoo.com/performance/rules.html
==- I say: Keep it EZ -==
smithjon
#6 2015-02-19 09:16

 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 af gsdfgvsd f

asad
pieter
#7 2015-02-19 10:20

What do you want to do?

... can we help you ...