Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-05-20 03:34:42

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Only Count Number of Future Articles?

Building a calendar-based website. Each event is assigned to a category. In the left nav, I have a list of categories with a count of events respective to that category.

For most applications, something like mdm_count is perfect. However, I only want to count FUTURE events. I just need to output the number.

I’ll take any clues you guys might have.


Kevin
(graphicpush)

Offline

#2 2011-05-20 09:30:37

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

Re: Only Count Number of Future Articles?

rah_function can probably do that.

Offline

#3 2011-05-20 12:47:54

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Only Count Number of Future Articles?

Els wrote:

rah_function can probably do that.

Yes it can, so probably could smd_query. With rah_function it should be relatively simple, something along the lines:

<txp:rah_function call="safe_count" table="textpattern" where='Status=4 and Posted > now() and (Category1="<txp:category />" or Category2="<txp:category />")' />

If the code is used in public scope and the category is user-changeable, basically taken directly from the requested URL (as category tag would do in public scope, outside category listings) you would need to additionally escape the input to prevent external injections. This could be done by using doSlash(), same code otherwise:

<txp:rah_function call="safe_count" table="textpattern" where='Status=4 and Posted > now() and (Category1="<txp:rah_function call="doSlash"><txp:category /></txp:rah_function>" or Category2="<txp:rah_function call="doSlash"><txp:category /></txp:rah_function>")' />

Last edited by Gocom (2011-05-20 13:33:10)

Offline

#4 2011-05-20 20:57:45

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: Only Count Number of Future Articles?

rah_function code worked amazingly, perfectly well. Thank you so much.


Kevin
(graphicpush)

Offline

Board footer

Powered by FluxBB