Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Plugin support
  3. » mdn_count

#106 2016-09-30 10:43:14

etc
Developer
Registered: 2010-11-11
Posts: 5,673
Website GitHub

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

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

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

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: mdn_count

Dragondz wrote #302935:

What s NULLDATETIME, i havent found anything even on google!

You can find some info on the forum using the search engine.
Does this help in your case?


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#109 2016-11-16 09:59:28

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: mdn_count

Merci Nicolas

To make mdn_count work i had to change line 46 like this:

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

Offline

#110 2016-11-16 11:02:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,438
Website GitHub

Re: mdn_count

Dragondz wrote #302935:

Unknown column ‘NULLDATETIME

Here’s the plugin fix from a post the other day.

I added define('NULLDATETIME', '\'0000-00-00 00:00:00\'');... to the plugin and the error vanished.

Not advisable. The reason it was removed is because MySQL and its various forks are starting to remove support for zero dates. Results are undefined if you use them and vary from version to version. If you feel you must use it, this is better:

define('NULLDATETIME', '\'1970-01-01 12:00:00\'');

But changing the code as you’ve done to use IS NULL is far better.


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

Hire Txp Builders – finely-crafted code, design and Txp

Online

#111 2016-11-16 12:02:20

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Offline

#112 Yesterday 20:04:14

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 725
Website Mastodon

Re: mdn_count

Since updating to 4.9 sthg like

<txp:custom_field name="band_name" /> (<txp:mdn_count customfield="band_name" customvalue='<txp:custom_field name="band_name" />' />)

supposed to count the number of entries in a particular custom field does not display the result anymore.
Anyone aware of this?
I’d be happy to get rid of mdn_count altogether otehrwise, but haven’t a new way of counting those entries.

Thanks for any pointers.

Last edited by jayrope (Yesterday 20:13:04)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#113 Yesterday 20:29:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: mdn_count

jayrope wrote #342489:

I’d be happy to get rid of mdn_count altogether otehrwise, but haven’t a new way of counting those entries. Thanks for any pointers.

That should be possible. Oleg gave a pointer a few posts up and here’s an example of that in use.

This is the Textpattern welcome article. You can delete or edit it and then start creating your own content.

Textpattern in two minutes provides an overview of Textpattern. Textpattern user documentation provides more detailed information.

For example, if you have a list of articles with song titles and a custom_field band_name, this will return your article counts:

The Beatles: <txp:article_custom band_name="The Beatles" pageby="1" pgonly />
Rolling Stones: <txp:article_custom band_name="Rolling Stones" pageby="1" pgonly />

You can get a comma-separated list of your band names using

<txp:article_custom break="," sort="custom_1 desc" variable="all_band_names" trim>
<txp:if_different><txp:custom_field name="band_name" /></txp:if_different>
</txp:article_custom>

(assuming band_name = custom_1)

From that you could build an automated list…


TXP Builders – finely-crafted code, design and txp

Offline

#114 Yesterday 22:07:22

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 725
Website Mastodon

Re: mdn_count

Hey Jakob, Du bist immer so am Start, herzlich Dankeschön!

I can’t quite see somehow, how your example would just return a number, the actual count of articles using a particular custom field entry…
I am using my above script in an article body, in between text. Can you elaborate?

Last edited by jayrope (Yesterday 22:07:42)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#115 Yesterday 22:21:05

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: mdn_count

jayrope wrote #342491:

I can’t quite see how your example would just return a number, the actual count of articles … Can you elaborate?

Have a look at the two attributes in the article_custom docs:

  • pgonly outputs the number of pages (of results) as a number, and
  • setting pageby="1" means you would be paging by every article instead of the default 10 per page.

The result is the number of matching results. The credit should go to Oleg, though.


TXP Builders – finely-crafted code, design and txp

Offline

#116 Yesterday 22:34:03

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 725
Website Mastodon

Re: mdn_count

jakob wrote #342493:

Have a look at the two attributes in the article_custom docs:

  • pgonly outputs the number of pages (of results) as a number, and
  • setting pageby="1" means you would be paging by every article instead of the default 10 per page.

The result is the number of matching results. The credit should go to Oleg, though.

I’ll try, thanks a lot. I always thought, that I should not use an article tag inside an article body. I’ll report back


A hole turned upside down is a dome, when there’s also gravity.

Offline

#117 Yesterday 23:49:28

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 725
Website Mastodon

Re: mdn_count

jakob wrote #342493:

Have a look at the two attributes in the article_custom docs:

  • pgonly outputs the number of pages (of results) as a number, and
  • setting pageby="1" means you would be paging by every article instead of the default 10 per page.

The result is the number of matching results. The credit should go to Oleg, though.

This has worked, thanks a lot! So i got rid of mdn_count finalmente.

I found a bug, though. Using

<txp:article_custom band_name="<txp:custom_field name="band_name" />" pageby="1" pgonly />

with an entry in the custom field containing an “&” (an ampersand) does not count that entry and
reports a count of zero, instead of counting and reporting the respective entry as 1.
You can see the live example on https://www.kliklak.net/live-dates/past-concerts-by-artist

Namely the custom field called “band_name” containing “jayrope & Ansgar Wilken” counts zero, whereas “jayrope + Ansgar Wilken” using a “+” sign instead of an ampersand counts 1 per entry. Oopsie :)

Very small bug, is that a 4.9 issue? I am wondering where to report this.

Last edited by jayrope (Yesterday 23:53:14)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#118 Today 00:22:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,438
Website GitHub

Re: mdn_count

Try single quotes when you use tags-in-attributes so the content is parsed :)

<txp:article_custom band_name='<txp:custom_field name="band_name" />' pageby="1" pgonly />

If that still doesn’t work, we’ll go from there and investigate reasons.


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

Hire Txp Builders – finely-crafted code, design and Txp

Online

  1. Index
  2. » Plugin support
  3. » mdn_count

Board footer

Powered by FluxBB