Memorial Day
Support will be closed on Monday, May 28th, 2012 to enjoy Memorial Day with our friends and families.
   
 
Plugin: Category Info
Posted: 19 January 2009 11:10 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

The attached add-on files may be out of date.  Please visit Devot-ee for the latest versions.

I would like to present to your attention a new plugin: Category Info. This plugin allows you to output info about certain category without specifying anything about weblog or entries.

PARAMETERS:

1) category_id - Required. Allows you to specify category id number.

2) site - Optional. Allows you to specify site id number.

3) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when
the plugin has some problem with parameters,  PHP alert is being shown;
if the value is “silence”, then in cases when the plugin has
some problem with parameters, it finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

VARIABLES:

1) {cat_info_category_group_name}

2) {cat_info_category_group}

3) {cat_info_parent_category_id}

4) {cat_info_category_name}

5) {cat_info_category_url_title}

6) {cat_info_category_description}

7) {cat_info_category_image}

8) {cat_info_subcategories_number}

9) {cat_info_nonempty_subcategories_number}

Also the values of custom category fields can be retrieved using their names with “cat_info_” appended. E.g. if there is custom category field named “my_field”, its value can be outputted using variable {cat_info_my_field}.

Conditionals are supported.

EXAMPLE OF USAGE:

{exp:cat_info category_id="{segment_3}"}

{if cat_info_category_group
=="3"}
Some code
{
/if}

{if cat_info_category_group
=="45"}
Some code
{
/if}

{
/exp:cat_info} 
 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 19 January 2009 11:38 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  104
Joined  09-19-2006

Nice! Will this accept a “C3” type segment as the category_id parameter?

Profile
 
 
Posted: 19 January 2009 11:51 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Will this accept a “C3” type segment as the category_id parameter?

No. If “C3” means “category having category id 3”, then you first should strip the letter “C”. To do this you can use my other plugin called “Find and Replace Plus”.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 13 March 2009 11:16 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi,

I released version 1.1 of Category Info plugin.

in this release a new variable - {cat_info_subcategories_number} - was added. It outputs the number of subcategories.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 20 March 2009 12:44 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Avatar
Total Posts:  7
Joined  03-08-2009

I just wanted to pass on my thanks for your great plugins. Both this and the category_id plugin have made my transition to EE a great success, and much smoother than expected. My regards.

Profile
 
 
Posted: 28 March 2009 03:08 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi,

I released version 1.2 of Category Info plugin.

New features:

1) “invalid_input” optional parameter. It accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when
the plugin has some problem with parameters,  PHP alert is being shown;
if the value is “silence”, then in cases when the plugin has
some problem with parameters, it finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

2) variable {cat_info_nonempty_subcategories_number} - outputs number of non-empty subcategories.

3) support for custom category fields. Values of custom category fields can be retrieved using their names with “cat_info_” appended. E.g. if there is custom category field named
“my_field”, its value can be outputted using variable {cat_info_my_field}.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 14 August 2009 10:22 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

Getting a PHP Notice error:

Notice: Undefined variable: conds2 in /nfs/c05/h01/mnt/71344/domains/mysc.org/html/mysccontrol/plugins/pi.cat_info.php on line 192

I wouldn’t normally care, except that having the error is interfering with some other parsing on the page somehow!

Profile
 
 
Posted: 14 August 2009 12:08 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi Adrienne,

If error message is the only problem, you can easily suppress it bu using PHP error control operator. E.g.:

// Typical Example
$var = @some_function(); 
 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 14 August 2009 01:30 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

Right, except that it’s ALSO causing issues with parsing for the errors to be on. I did fix the problem, at least temporarily, by changing the display of errors to logged-in users via the EE control panel. but it might be a good idea to sort out WHY that notice is happening, for your next version! smile

Profile
 
 
Posted: 14 August 2009 01:44 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Of course I will try to fix it.

You will help to fix if you can provide a snippet of code which produces the error.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 14 August 2009 01:47 PM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

...oops, sorry, forgot about that. I’m a dork. :) Here’s a fairly minimal sample:

{exp:weblog:category_heading weblog="section_gallery"}

{embed
="includes/.declarations" 
    
pagetitle="
     {if "
{parent_id}" > 0}
       {exp:cat_info category_id="
{parent_id}"}
          {cat_info_category_name}
       {/exp:cat_info}
     {/if}
    "
}

{
/exp:weblog:category_heading} 
Profile
 
 
Posted: 16 August 2009 06:16 AM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi Adrienne,

Grab the version 1.2.1 - I fixed the bug.

Thanks for reporting.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 22 October 2009 07:41 PM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  04-01-2008

Great Plugin Laisvunas.

I made a few modifications to accept either the category_id or the category_url as a required parameter. Often we have the category_url from a segment (instead of the id).  I also added a new output tag so that the category id would then be available for output if you input the category url.

{cat_info_category_id}

 Signature 

brilliantretail.com | Developers  | Support | Purchase


David Dexter

Profile
 
 
Posted: 24 October 2009 07:16 AM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi dpdexter,

When I have category_url_title from the segment and need category_id, I convert category_url_title into category_id using Category Id plugin.

It is not very good to allow category_url_title to represent category since category_url_title does not allow to identify category uniquely (category_url_title is unique only within its category group).

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 24 October 2009 12:22 PM   [ Ignore ]   [ # 14 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  04-01-2008

Ah - good point. For our particular use case it worked beautifully because our project allows users to build categories dynamically on the front end and the category url title is unique because we were prepending the parent category url title to the new url title.

Thank you for the feedback. Lesson learned.

Best,
David

 Signature 

brilliantretail.com | Developers  | Support | Purchase


David Dexter

Profile
 
 
Posted: 22 January 2010 04:31 PM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  30
Joined  09-02-2008

Thanks for this plugin.  When using on an MSM site, it wouldn’t work without specifying the site_id though.

Profile
 
 
Posted: 26 February 2010 04:35 AM   [ Ignore ]   [ # 16 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi,

I released version 1.2.2 of Category Info plugin. In this releases a bug were fixed - PHP error about undefined variable being displayed in some cases.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 15 June 2010 08:20 AM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1158
Joined  02-02-2007

Hi,

I released version 1.3 of Category Info plugin.

In this release a new variable - {cat_info_category_group_name} - was added.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile