Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-11-11 16:11:53

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Article Count

My project (and many others that I maintain) have a requirement where data(articles) needs to have a visible count or number displayed on the frontend of the site. I’ve been using mdn_count for quite a while and since upgrading to TXP 4.6X it has stopped working.

I’m not a big fan of using plugins for this reason. I’ve since had to downgrade to v1.4 of mdn_count to get it working again, so I lose newer features.

Is there ANY other way to get a native article count in TXP like the way mdn_count works? The logic exists as seen in the Categories section… it shows the article count based on the category.

Things I’m looking to accomplish:
1. A total article count.
2. Article count based on section.
3. Article count based on category.

This is basic stuff in pretty much any other CMS. I love Textpattern and don’t want to switch, but I am already 50% done converting all my TXP logic over to Symphony CMS because an article count is as simple as <xsl:value-of select="count()" />.

Is there something I’m overlooking, is my terminology incorrect? Is there an easier way to accomplish what I’m looking for?

Offline

#2 2016-11-11 16:21:50

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,623
Website

Re: Article Count

I guess the forthcoming txp:evaluate tag might be able to do the job. But Oleg is the expert on this one:)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github
I do my best editing after I click on the submit button.

Online

#3 2016-11-11 16:33:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,032
Website

Re: Article Count

In the meantime, edit the plugin. Find the line that mentions NULLDATETIME and replace it with this:

$q[] = $andor.' (Posted <= now() and (now() <= Expires or Expires IS NULL))';

Untested, but it should work.

If there’s an issue with getting counts from Txp natively, just raise an issue and we’ll add tags to do it. I’ve never had to do it and didn’t realise it was a “basic” requirement, hence it’s not been done.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2016-11-11 17:09:28

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: Article Count

Bloke wrote #302825:

If there’s an issue with getting counts from Txp natively, just raise an issue and we’ll add tags to do it. I’ve never had to do it and didn’t realise it was a “basic” requirement, hence it’s not been done.

Thanks for the info.

When you say “raise an issue”, do you mean on GitHub?

Offline

#5 2016-11-11 17:11:09

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,738

Re: Article Count

qrayg wrote #302826:

When you say “raise an issue”, do you mean on GitHub?

Yep – here: github.com/textpattern/textpattern/issues/new

Offline

#6 2016-11-11 17:55:18

etc
Developer
Registered: 2010-11-11
Posts: 3,573
Website

Re: Article Count

qrayg wrote #302823:

This is basic stuff in pretty much any other CMS. I love Textpattern and don’t want to switch, but I am already 50% done converting all my TXP logic over to Symphony CMS because an article count is as simple as <xsl:value-of select="count()" />.

A patch already exists in 4.7 to enhance <txp:article_custom /> with count functionality. Symphony way is possible with etc_query too, but if you only need to count articles, without outputting them, it is sub-optimal (in Symphony too).

Offline

#7 2016-11-11 18:13:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,032
Website

Re: Article Count

Sorry about the terseness of my reply. I was on my way out the door and just threw my answer out there.

I wasn’t being flippant or anything, it’s just that the reason it’s not been done so far has been the perceived lack of people asking for the functionality. Maybe mdn_count has satisfied people all these years, which is why few have asked for it!

Anyway, as etc says, whichever method you choose, you do need to be careful to do it in an optimal way or you could hurt your user’s experience with an expensive query.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2016-11-11 18:50:38

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,241
Website

Re: Article Count

It doesn’t really address the issue of going plugin-free but an alternative using adi_calc (which was updated for the 4.6 tag registry) is:

<txp:variable name="article-count" value="0" />

<txp:article_custom section="[articles]" category="[articles]" limit="9999">
 <txp:adi_calc name="article-count" add="1" />
</txp:article_custom>

Offline

#9 2016-11-11 19:14:16

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: Article Count

michaelkpate wrote #302830:

It doesn’t really address the issue of going plugin-free but an alternative using adi_calc (which was updated for the 4.6 tag registry) is:

<txp:variable name="article-count" value="0" />...

Thank you, michaelkpate… I was actually looking at adi_calc and smd_query to accomplish my goal. This example was VERY helpful. I truly appreciate it.

Offline

#10 2016-11-12 03:06:35

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,241
Website

Re: Article Count

qrayg wrote #302831:

Thank you, *michaelkpate*… I was actually looking at adi_calc and smd_query to accomplish my goal. This example was VERY helpful. I truly appreciate it.

You are welcome. You might also want to check out this thread

Offline

Board footer

Powered by FluxBB