Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-11-12 14:24:36

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: jmd_count: Count MySQL tables

Is it possible with jmd_if_count to use more than one parameter in the where attribute?

I need to test the number of articles returned in a yearly archive page, so I need to limit by both section and date.

My unsuccessful suck it and see test was this:

<txp:jmd_if_count table="textpattern" eval=">1" where="section='news' AND year='2009'">there's more than 1</txp:jmd_if_count>

But in reality I’d need to pull the year value from a txp:variable too, so that might complicate the syntax even further – something like:

<txp:jmd_if_count table="textpattern" eval=">1" where="section='news' AND year='<txp:variable name="this_year" />'">there's more than 1</txp:jmd_if_count>

cheers

Stu

Offline

#14 2009-11-12 16:12:56

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

Re: jmd_count: Count MySQL tables

pieman wrote:

My unsuccessful suck it and see test was this:

The plugin uses SQL. There isn’t a field called date. Also when you use = sign, it matches the value as is. No posted date is just exactly “2009”, but unix datetime.

Posted rlike '<txp:variable name="this_year" />' and section="news"

Offline

#15 2009-11-12 16:36:55

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: jmd_count: Count MySQL tables

Gocom wrote:

The plugin uses SQL. There isn’t a field called date.

Duh. Of course, sorry. I’ve successfully crammed the year into the month attribute of article_custom before and was clumsily trying to achieve the same thing.

Posted rlike '<txp:variable name="this_year" />' and section="news"

Thanks for your help but I’m not sure how that could work in this context. Do you mean to use it inside the where attribute?

<txp:jmd_if_count table="textpattern" eval=">2" where="Posted rlike '<txp:variable name="this_year" />' and section='news'">more than 1 - </txp:jmd_if_count>

I suspect I still have the wrong end of the stick, because that throws errors.

Offline

#16 2009-11-12 18:13:48

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

Re: jmd_count: Count MySQL tables

pieman wrote:

I suspect I still have the wrong end of the stick, because that throws errors.

If you want to use <txp:tags /> inside parameters, you need to surround the value with single quotes instead double; foo="bar" to foo='bar'. Example:

[...]where='Posted rlike "<txp:variable name="this_year" />" and section="news"'[...]

Offline

#17 2009-11-12 20:48:51

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: jmd_count: Count MySQL tables

Perfect, thanks for clarifying that Jukka.

Offline

#18 2009-11-14 21:38:12

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: jmd_count: Count MySQL tables

I should be paying you in txdollars (an upcoming currency), Jukka. Thanks for providing support!

Offline

#19 2009-11-15 20:30:30

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

Re: jmd_count: Count MySQL tables

jm wrote:

I should be paying you in txdollars (an upcoming currency), Jukka. Thanks for providing support!

We’ve been waiting for this day to come ;) Txnation and txdollars.

Offline

Board footer

Powered by FluxBB