1 of 2
1
Plugin:  Entries Number
Posted: 16 June 2008 08:47 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi,

I would like to present to your attention a new plugin: Entries Number. It allows to find number of entries posted into certain weblogs and/or into certain categories and/or having
certain url_title or entry_id.

The idea to write such plugin may seem strange: {exp:weblog:entries} tag has {total_results} variable, which can be used in conditionals, and if no_results conditional.

The problem is that in case you use no_results conditional, you cannot wrap {exp:weblog:entries} tag into a plugin. That is, the code as this

{exp:category_id category_group="3" category_url_title="segment_3" parse="inward"}
{exp
:weblog:entries weblog="my_weblog" category="{category_id}"}
{if no_results}
No entry found
!
{/if}
{
/exp:weblog:entries}
{
/exp:category_id}

will not work.

In order to be able to find number of entries and to use other plugins at the same time I have developed this plugin.

PARAMETERS:

1) category - Optional. Allows you to specify category id number
(the id number of each category is displayed in the Control Panel).
You can stack categories using pipe character to get entries
with any of those categories, e.g. category=“3|6|8”. Or use “not”
(with a space after it) to exclude categories, e.g. category=“not 4|5|7”.
Also you can use “&” symbol to get entries each of which was posted into all
specified categories, e.g. category=“3&6&8”.

2) weblog - Optional. Allows you to specify weblog name.
You can use the pipe character to get entries from any of those
weblogs, e.g. weblog=“weblog1|weblog2|weblog3”.
Or you can add the word “not” (with a space after it) to exclude weblogs,
e.g. weblog=“not weblog1|weblog2|weblog3”.

3) author_id - Optional. Allows you to specify author id number.
You can use the pipe character to get entries posted by any of those
authors, e.g. author_id=“5|11|18”.
Or you can add the word “not” (with a space after it) to exclude authors,
e.g. author_id=“not 1|9”.

4) site - Optional. Allows you to specify site id number.
You can stack site id numbers using pipe character to get entries
from any of those sites, e.g. site=“1|3”. Or use “not”
(with a space after it) to exclude sites, e.g. site=“not 1|2”.

5) status - Optional. Allows you to specify status of entries.
You can stack statuses using pipe character to get entries
having any of those statuses, e.g. status=“open|draft”. Or use “not”
(with a space after it) to exclude statuses,
e.g. status=“not submitted|processing|closed”.

6) url_title - Optional. Allows you to specify url_title of an entry.

7) entry_id - Optional. Allows you to specify entry id number of an entry.

8) show_expired - Optional. Allows you to specify if you wish expired entries
to be counted. If the value is “yes”, expired entries will be counted; if the
value is “no”, expired entries will not be counted. Default value is “yes”.

9) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when some
parameter’s value is invalid plugin exits and PHP alert is being shown;
if the value is “silence”, then in cases when some parameter’s value
is invalid plugin finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

VARIABLES:

1) entries_number - outputs the number of entries which satisfy condition
entered in prameters.


EXAMPLE OF USAGE:

{exp:entries_number category="6" weblog="not weblog1|weblog4" site="1"}
{entries_number}
{
/exp:entries_number}

The variable {entries_number} placed between {exp:entries_number} and {/exp:entries_number} tags
will output the number of entries which satisfy condition entered in prameters.

You can use {entries_number} variable in conditionals:

{exp:entries_number category="6" weblog="not weblog1|weblog4" site="1"}
{if entries_number
==0}
Some code
{if
:elseif entries_number==1}
Some other code
{if
:else}
Yet another code
{
/if}
{
/exp:entries_number}

In contrast with “if no_results” conditional, which does not allow its parent tag {exp:weblog:entries} to be
wrapped in a plugin, contionals inside {exp:entries_number} does not interfere with outer plugins. That is, the code as this

{exp:category_id category_group="3" category_url_title="segment_3" parse="inward"}
{exp
:entries_number weblog="my_weblog" category="{category_id}"}
{if entries_number
==0}
No entry found
!
{/if}
{
/exp:entries_number}
{
/exp:category_id}


will work properly.

Changelog:

-1.6 // Added “author_id” parameter.
-1.5 // Added “show_expired” parameter.
-1.4 // Added possibility to use “&” in “category” parameter values. Fixed bug - entries number being equal to “0” when “status” parameter has a value consisting of two strings and space symbol between them. Fixed bug - entries posted into several categories being counted several times.
-1.3 // Added “status” parameter.
-1.2 // Added “invalid_input” parameter.
-1.1 // Made possible to use {entries_number} variable both inside and outside conditional at the same time.
-1.0 // First release.

File Attachments
pi.entries_number_v1.6.zip  (File Size: 5KB - Downloads: 5)
 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 09 July 2008 08:18 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  15
Joined  06-24-2008

Oh, I love you - this is exactly what I was needing to display some info for a GeoRSS feed!! (posts per category)

You da man! Worked like a charm.

Profile
 
 
Posted: 30 July 2008 09:11 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  3
Joined  01-08-2008

This plugin is a god send. Thank you!!

Profile
 
 
Posted: 16 August 2008 03:44 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  162
Joined  09-06-2006

Is there a way to use this in a calendar to show number of entries for each day?

 Signature 

Kyle Summer | smartpill design | New Haven, CT

Profile
 
 
Posted: 17 August 2008 02:37 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Is there a way to use this in a calendar to show number of entries for each day?

Since plugin has no “date” parameter it cannot output number of entries posted on particular day.

It seems that you can use Query module for this purpose.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 26 August 2008 09:48 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi,

I have released a version 1.2 of Entries Number plugin.

In this release parameter “invalid_input” was added. This parameter accepts two values: “alert” and “silence”. Default value is “silence”. If the value is “alert”, then in cases when some parameter’s value is invalid plugin exits and PHP alert is being shown;
if the value is “silence”, then in cases when some parameter’s value
is invalid the plugin finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

Since the plugin does not do comprehensive validation of parameters’ values, you cannot be absolutely sure that in cases no alert was thrown the input was really valid.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 03 September 2008 02:03 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Avatar
Total Posts:  10
Joined  11-30-2007

This plugin has made my life so much better. Thank you!

Profile
 
 
Posted: 28 September 2008 03:04 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

If this plugin could do status as well, that would be fantastic. For example, I’m looking to find the count of entries of Category A, that have a status of “Draft”. Maybe I could combine this plugin with a query module query to get what I need?

This is relatively handy for outputting all entries, but I think a status filter would make it much more useful to me! Any suggestions on how else I could achieve what I’m after without having to resort to the too-heavy wegblog:entries tag would be appreciated, too.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 29 September 2008 03:40 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi mdesign,

You made a very good suggestion.

I have uploaded a new release - 1.3 - of Entries number plugin in which “status” parameter is introduced. As with “status” parameter of exp:weblog:entries tag you can choose multiple statuses using a pipe character:

status="draft|reviewed|published"

Or exclude statuses using “not”

status="not submitted|processing|closed"

Grab the new version using the link in the first post and let me know if something goes wrong.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 29 September 2008 08:25 AM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

Oh yes, with the addition of “status” this just became enormously useful all over the place. I had bulky weblog:entries tags with everything disabled just to get simple entry counts - but this plugin will replace all of those perfectly!

Thank you for updating this so quickly.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 16 November 2008 05:08 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Hi Laisvunas,

Thanks for notifying me about this plugin.  I’m have been unable to get the correct number of entries to appear with the following code:

{exp:entries_number weblog="weblog1" category="4&131;"}
{category_name} {entries_number}
<<
{/exp:entries_number}

The results show the name of category “4” and the number of entries in category 4.

I’m trying to show the number of entries that belong to both category 4 AND 131.

Thanks

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
Posted: 16 November 2008 06:08 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Hi Laisvunas,

I think I may have discovered a bug:  If the status is made of two words, it doesn’t work.

I have 4 status values,  3 of them are a single word and they work properly the 4th one “Pender Harbour” does not work.

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
Posted: 17 November 2008 07:12 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi Logtenberg,

I’m have been unable to get the correct number of entries to appear with the following code:

{exp:entries_number weblog="weblog1" category="4&131;"}
{category_name} {entries_number}
<<
{/exp:entries_number}

The results show the name of category “4” and the number of entries in category 4.

I’m trying to show the number of entries that belong to both category 4 AND 131.

If you need to show the number of entries that belong to both category 4 and 131 your code should be:

{exp:entries_number weblog="weblog1" category="4|131"}
{entries_number}
{
/exp:entries_number}

I think I may have discovered a bug:  If the status is made of two words, it doesn’t work.

I will check it.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 17 November 2008 01:02 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Hi Laisvunas,

I think there is a misunderstanding regarding listing the number of entries belonging to 4 AND 131.

When I use the pipe character, it appears that the number of entries is the sum of all entries in category 4 and all entries in 131.  What I instead need is the sum of entries that belong to both categories.

ie.

entry 1 (belongs to category 4, belongs to category 131)
entry 2 (belongs to category 4 only)
entry 3 (belong to category 131 only)

so if I had 3 entries, the entries_number would be “1”  <—this is what I need.
with the | character, the entries_number would be “3”

——

The reason I need this, is that I have 2 category groups - the first group is “type”, the second group is “location”.  So I need a count of how many entries of a certain type are at a certain location.

Thanks
Ryan

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
Posted: 17 November 2008 11:54 PM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi Ryan,

Now I understand what you meant. I will consider this feature preparing the next release of Entries Number plugin.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 18 November 2008 12:07 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Very cool.

Thanks!!

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
Posted: 28 November 2008 09:48 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi all,

I have released version 1.4 of Entries Number plugin.

In this release:

1) Added possibility to use “&” in “category” parameter values. Using this symbol you can get entries each of which was posted into all specified categories, e.g. category=“3&6&8” will get entries each of which was posted into category “2”, into category “6” and into category “8”.

2) Fixed bug - entries number being equal to “0” when “status” parameter has a value consisting of two strings and space symbol between them.

3) Fixed bug - entries posted into several categories being counted several times.

Everyone who uses this plugin is recommended to upgrade.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 28 November 2008 01:40 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Sweeet! thanks Laisvunas!

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
Posted: 28 November 2008 02:18 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  440
Joined  11-12-2003

Hi Laisvunas,

I just noticed that it is counting entries for me that are expired.  I added this as a parameter show_expired=“no”  and it didn’t work. I guess that parameter isn’t recognized.

Would it be possible to have by default that expired entries are not counted? or perhaps that you can allow for this conditional to work?

I’m So close…

Thanks!

 Signature 

version 1.6.4
Build:  20080829

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65086 Total Logged-in Users: 35
Total Topics: 82224 Total Anonymous Users: 16
Total Replies: 441922 Total Guests: 192
Total Posts: 524146    
Members ( View Memberlist )