Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
Re: jmd_count: Count MySQL tables
Perfect, thanks for clarifying that Jukka.
Offline
Re: jmd_count: Count MySQL tables
I should be paying you in txdollars (an upcoming currency), Jukka. Thanks for providing support!
Offline
Offline