Plugin:  Entries Number
Posted: 16 June 2008 09:47 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
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”.

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) 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”.

4) 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”.

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

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

7) 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.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.3.zip  (File Size: 4KB - Downloads: 14)
 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 09 July 2008 09:18 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  14
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 10:11 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  1
Joined  01-08-2008

This plugin is a god send. Thank you!!

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

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

Profile
 
 
Posted: 17 August 2008 03:37 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
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 10:48 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
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 03: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 04:04 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1578
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 04:40 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
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 09:25 AM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1578
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
 
 
   
 
 
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 10:33 AM
Total Registered Members: 62591 Total Logged-in Users: 15
Total Topics: 77059 Total Anonymous Users: 15
Total Replies: 416203 Total Guests: 164
Total Posts: 493262    
Members ( View Memberlist )
Active Members:    3000adam.beaughCrucialcybermanDevStudioGert TimmermanhearsayJesse B.JohnDkbhookunmikeejaySmopspiritbasedtosz25wuwongy