Dotclear

Vous n'êtes pas identifié(e).

Annonce

#1 2014-10-02 18:23:35

jarekb
Membre
Inscription : 2014-09-06

Last Comments - how to modify this widget?

Hello,

By default Last Comments widget shows the comments like that:

Post_Title - Name_Of_Some_Comment_Author3
Post_Title - Name_Of_Some_Comment_Author2
Post_Title - Name_Of_Some_Comment_Author1
(if the last 3 comments was on the same post)

I would like to change it to:

Last_Post_Title - Number_Of_Comments_For_Last_Post_Title
Previously_Commented_Post_Title - Number_Of_Comments_For_PCPT
One_Before_Previously_Commented_Post_Title - Number_Of_Comments_For_OBPCPT

Is it possible? Which file need to be modified?

Any help appreciated.

Hors ligne

#2 2014-10-02 18:30:29

jarekb
Membre
Inscription : 2014-09-06

Re : Last Comments - how to modify this widget?

OK, I've found the code in plugins/widgets/_widget_functions.php:

	public static function lastcomments($w)
	{
		global $core;

		if (($w->homeonly == 1 && $core->url->type != 'default') ||
			($w->homeonly == 2 && $core->url->type == 'default')) {
			return;
		}

		$params['limit'] = abs((integer) $w->limit);
		$params['order'] = 'comment_dt desc';
		$rs = $core->blog->getComments($params);

		if ($rs->isEmpty()) {
			return;
		}

		$res = ($w->content_only ? '' : '<div class="lastcomments'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
		($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '').
		'<ul>';

		while ($rs->fetch())
		{
			$res .= '<li class="'.
			((boolean)$rs->comment_trackback ? 'last-tb' : 'last-comment').
			'"><a href="'.$rs->getPostURL().'#c'.$rs->comment_id.'">'.
			html::escapeHTML($rs->post_title).' - '.
			html::escapeHTML($rs->comment_author).
			'</a></li>';
		}

		$res .= '</ul>'.($w->content_only ? '' : '</div>');

		return $res;
	}

It's probably last 10 lines to be modified. Unfortunately I'm less than noob in php :(

Hors ligne

#3 2014-10-02 19:13:51

Jean-Michel
Modérateur à ailes d'ange
Lieu : Paris
Inscription : 2006-08-22
Site Web

Re : Last Comments - how to modify this widget?

View this plugin.

Hors ligne

#4 2014-10-02 21:25:36

jarekb
Membre
Inscription : 2014-09-06

Re : Last Comments - how to modify this widget?

Hello Jean-Michael,

Thank you for quick answer. It's big progress, but this plugin does only part of the job. Now I have comment title + date showing, and that's good :-)

The missing part is:
When 2 persons or more add a comment to the same post (for example, at the same day), the same post title is showing 3 times, because DC counts the same post three times

The same post title
The same post title
The same post title

The goal is to get this order:

Title of last commented post
Diffrerent title of previous commented post
Another different post title from the past

(Sorry for my English, not a native speaker)

Dernière modification par jarekb (2014-10-02 21:27:11)

Hors ligne

#5 2014-10-02 21:26:49

pierrevg
Membre
Inscription : 2005-04-13
Site Web

Re : Last Comments - how to modify this widget?

Le support de dcom est abandonné. Lui préférer LCE.

Hors ligne

Vous n'êtes pas identifié(e).

Pied de page des forums

Sites map