Core Modules & Blocks  :: 
How can I show article count in category menu?
 Top

  • I'm looking to add a total count of articles for each category in my menu. I have searched the forum and google and have found nothing that resembles what I'm trying to do. I was hoping that one of you could help me out with the code.

    I display a Core/category block on the left side that shows a list of my story categories.

    e.g.

    Category Menu
    * Category 1
    * Category 2
    * Category 3
    etc.

    what I'd like to do is have this

    Category Menu
    * Category 1 (13 articles)
    * Category 2 (8 articles)
    * Category 3 (2 articles)
    etc.

    where the respective article (story) count is displayed in parenthesis next to the category name.

    I hope this makes sense. Any help is appreciated.
  • You'll have to modify the block's code - check includes/blocks/

    Add a count parameter to the SQL query, put that in a variable, and output it. More than that I can't really say.

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Quote

    Add a count parameter to the SQL query, put that in a variable, and output it

    How do I do that? I'm not a PHP programmer so I need some guidance with this part. Appreciate what you can give me.
  • Code

    $query = "SELECT $cattables[title], count(*)
                  FROM $cattable
                  GROUP BY $cattables[title]"
    ;


    is the sort of query, but you'll have to work that into the block yourself.

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
This list is based on the users active over the last 60 minutes.