Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-06 19:24:56

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

List articles by comment count, most recent comments, etc.

There may be a FAQ article on this— if so, please point me in the right direction.

I need Textpattern to generate some lists on the homepage, as follows:

  1. A list of articles sorted by most comments. This would include an article excerpt and a link to each article.
  2. A list of articles sorted by most recent comments. This would probably include an excerpt of the comment and a link to the article.

What Textpattern tags and/or plugins would be necessary to accomplish this?

Thank you!

Offline

#2 2008-11-06 20:27:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: List articles by comment count, most recent comments, etc.

Not really what you are looking for but jnm_recent_comments_unique might be of some help.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2008-11-06 23:05:39

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List articles by comment count, most recent comments, etc.

johnstephens wrote:

A list of articles sorted by most comments. This would include an article excerpt and a link to each article.

<txp:article sort="comments_count desc" />

A list of articles sorted by most recent comments. This would probably include an excerpt of the comment and a link to the article.

This is not possible I think because the comments dates are not stored in the textpattern table.

Offline

#4 2008-12-17 17:17:08

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: List articles by comment count, most recent comments, etc.

Thank you Yiannis & Els! Both of these are particularly helpful.

<txp:article sort="comments_count desc" />

This outputs articles regardless of whether they have comments— and there aren’t any on the site yet, since it hasn’t launched. Is there a way to put in a conditional, so I get only articles with comments? Something like this?

<txp:if_variable name="articles_with_comments" value="" >
    <p>Coming soon: Most active discussions!</p>
    <txp:else />
    <txp:article sort="comments_count desc" />
</txp:if_variable>

This example could be all kinds of crooked— any ideas?

Offline

#5 2008-12-17 22:39:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List articles by comment count, most recent comments, etc.

John, the simplest solution I can think of is to wrap your article form’s content in <txp:if_comments> tags.

Offline

#6 2008-12-17 23:39:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List articles by comment count, most recent comments, etc.

OK, this should work.

Article form ‘yourform’ something like this:

<txp:if_comments>
	<txp:if_first_article><ul></txp:if_first_article>
		<li><txp:title /> (<txp:comments_count />)</li>
	<txp:if_last_article></ul></txp:if_last_article>
</txp:if_comments>

On the page:

<txp:variable name="articles_with_comments" value='<txp:article form="yourform" sort="comments_count desc" limit="1" />' />

<txp:if_variable name="articles_with_comments" value="">
	<p>Coming soon: Most active discussions!</p>
<txp:else />
	<txp:article form="yourform" sort="comments_count desc" />
</txp:if_variable>

Offline

#7 2008-12-18 01:26:14

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: List articles by comment count, most recent comments, etc.

Thank you, Els! Works like magic.

Now I’m getting a PHP error that seems unrelated:

Notice: Undefined offset: 1 in [...]/textpattern/lib/txplib_misc.php(574) : eval()'d code on line 97

This popped up on every page after I created the new form and edited the page template. I can’t find anything in the tag teace. Should I post a new topic?

Offline

#8 2008-12-18 01:31:04

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List articles by comment count, most recent comments, etc.

Oops! Since the tags work as expected it does indeed seem not related, but it’s odd that it only appeared after you added them… You’d better open a new topic in Troubleshooting about this, I don’t know much about these errors.

And if I caused this, apologies!

Offline

#9 2008-12-18 02:07:20

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: List articles by comment count, most recent comments, etc.

Thank you again— done.

Offline

Board footer

Powered by FluxBB