Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#97 2013-08-05 19:54:11
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: mdn_count
Thanks. That works!
However, now I can’t achieve the below conditional that I created.
What could be the problem?
Regards
<txp:variable name="total" value="<txp:mdn_count category='<txp:category />' status='4' />" />
<p>Articles in this category: <txp:variable name="total" /></p> <!-- this variable displays correctly -->
<txp:if_variable name="total" value="0"> <!-- this condition, never is fulfilled -->
<h3>NO LOADED PRODUCTS IN THIS CATEGORY</h3>
</txp:if_variable>
Offline
Re: mdn_count
This shouldn’t have worked:
<txp:variable name="total" value="<txp:mdn_count category='<txp:category />' status='4' />" />
As colak already mentioned, you have to escape the quotes when using txp tags inside txp tags. And here, you are using txp tags inside txp tags inside txp tags, so you have to escape each level.
<txp:variable name="total" value='<txp:mdn_count category=''<txp:category />'' status='4' />' />
Notice that here category=''<txp:category />''
I’ve typed two single quotes '
(and not a double quote "
).
Offline
#99 2013-08-05 21:19:46
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: mdn_count
Thanks Maniqui, but the problem here is not keep the value into the variable, in fact it works well. The problem is the condition never is fulfilled.
I am not be able to display a message when no there articles in a specific category.
How would you do? Is some wrong in my code?
Offline
#100 2013-08-05 22:43:09
- radneck
- Plugin Author
- Registered: 2005-07-03
- Posts: 109
Re: mdn_count
Either the quotes are still slightly off, or the category actually has no posts (try dumping out articles on the pages to test). If nothing else works, maybe use smd_if.
Offline
#101 2013-08-06 00:12:58
Re: mdn_count
First, just to keep any quoting-related issue out of this, you can rewrite this:
<txp:variable name="total" value="<txp:mdn_count category='<txp:category />' status='4' />" />
to this:
<txp:variable name="total"><txp:mdn_count category='<txp:category />' status='4' /></txp:variable>
Yes, we are still having one tag-in-tag, but well, brain hurts a little less in this second version.
Second, can you confirm that this <txp:mdn_count category='<txp:category />' status='4' />
outputs 0
?
Third, have you tried explicitly assigning 0
to the variable? Like this:
<txp:variable name="total">0</txp:variable>
And then check if the condition is triggered.
If that last one attempt doesn’t work, I’d say that the issue is that 0
is a falsy value, and it’s somehow short-circuiting the logic you are trying to implement.
(Textpattern internals seems to suggest that).
So, here is a workaround for this problem.
<txp:variable name="total"><txp:mdn_count category='<txp:category />' status='4' /></txp:variable> <!-- this variable will store a number, it can be 0, 1, 2, 3... etc -->
<txp:variable name="total_string">total_<txp:variable name="total" /></txp:variable> <!-- this variable will store a string, it can be "total_0", "total_1", "total_2"... etc -->
<p>Articles in this category: <txp:variable name="total" /></p> <!-- this variable displays correctly -->
<txp:if_variable name="total_string" value="total_0">
<h3>NO LOADED PRODUCTS IN THIS CATEGORY</h3>
</txp:if_variable>
Offline
#102 2013-08-06 04:41:08
Re: mdn_count
There is another method you could use
<txp:variable name="checkarticles" value='<txp:article_custom category=''<txp:category />'' limit="1" />' />
<txp:if_variable name="checkarticles" value="">
<h3>NO LOADED PRODUCTS IN THIS CATEGORY</h3>
<txp:else />
<p><txp:mdn_count category='<txp:category />' status="4" /></p>
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#103 2013-08-06 12:18:33
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: mdn_count
Guys, many thanks for your suggestions. Both work for me!
Finally, my code was like this:
<txp:variable name="total"><txp:mdn_count category='<txp:category />' status='4' /></txp:variable>
<txp:if_variable name="total" value="0">
<h3>NO LOADED PRODUCTS IN THIS CATEGORY</h3>
</txp:if_variable>
About Maniqui’s question
Third, have you tried explicitly assigning0
to the variable? Like this:
<txp:variable name="total">0</txp:variable>
Yes, and the conditional is met here. Surely, it was a quoting-related issue as you said. Although, I couldn’t understand why it didn’t work, since I displayed the variable’s value and it was correct when I tried in my way. :/
Anyways, I am thankful for your invaluable help.
Best regards
Offline
#104 2013-09-09 02:03:10
- radneck
- Plugin Author
- Registered: 2005-07-03
- Posts: 109
Re: mdn_count
Just a quick note to say that version 2.2 of this plugin is out, now supporting filtering by custom fields.
This will likely be the last feature release for this plugin.
Bug reports always welcome.
{Edited to rectify link. – Uli}
Last edited by uli (2013-09-09 10:19:18)
Offline
#105 2016-09-30 00:25:42
- msome
- Member
- Registered: 2015-09-16
- Posts: 32
Re: mdn_count
Hi.
Need support
In new version 4.6.0, does not work
(<txp:mdn_count section='<txp:section />' />)
Result: ()
Empty parentheses
If the plugin does not work anymore, but you need an alternative solution
Important..
______________A little bit later______________
I tried the old version of the plugin 1.4
mdn_count v.1.4 – Working
mdn_count v.2.2 – Does not work
Last edited by msome (2016-09-30 00:48:45)
Offline
#106 2016-09-30 10:43:14
Re: mdn_count
Makes me think that <txp:article_custom />
could accept pgonly
attribute (without setting the pagination stuff) and return just the number of pages in this case. Yay, nay?
Offline
#107 2016-11-16 09:36:18
Re: mdn_count
Hi
After upgrading to txp 4.6.2 i got this error :
Erreur de balise : <txp:mdn_count section="site" category='<txp:category />'/> -> Textpattern Error: Unknown column 'NULLDATETIME' in 'where clause' lors du traitement du module “Aucun” dans le gabarit “2016”
What s NULLDATETIME, i havent found anything even on google!
it refere to this line 46 :
$q[] = $andor.' (Posted <= now() and (now() <= Expires or Expires = '.NULLDATETIME.'))';
NULLDATETIME is not a mysql constant, then maybe a txp constant ? but i found nothing about it ?
UPDATE : it seems that the constant was defined on constants.php on txp 4.5.7 and before, but the constant is nt in new version,
I added
define('NULLDATETIME', '\'0000-00-00 00:00:00\'');
to the plugin and the error vanished.
Last edited by Dragondz (2016-11-16 09:58:44)
Offline
#108 2016-11-16 09:56:09
Offline