Number of articles in subcategories Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
Zheekan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Nov 01, 2014 6:42 pm

Number of articles in subcategories

Post by Zheekan » Mon Jan 30, 2023 8:36 pm

Hello!
I have a category with numerous subcategories.
Is there a way for me to display the combined number of articles in all subcategories?
It is quite important to be able to show the increase in number of articles through time, and it would be great not to have to do it manually.

Thank you!

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13322
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Number of articles in subcategories

Post by sozzled » Mon Jan 30, 2023 9:22 pm

Zheekan wrote:
Mon Jan 30, 2023 8:36 pm
Is there a way for me to display the combined number of articles in all subcategories?
Yes (but not out of the box). :)

Where (or how) would you like to do this? ???
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

Zheekan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Nov 01, 2014 6:42 pm

Re: Number of articles in subcategories

Post by Zheekan » Tue Jan 31, 2023 1:10 pm

sozzled wrote:
Mon Jan 30, 2023 9:22 pm
Yes (but not out of the box). :)
Where (or how) would you like to do this? ???
Of course :)

I made a website for a local community, and it's main use is putting certain locations on a map.
Map is populated by using joomla articles that are divided in one level of subcategories inside a root category, every article is also a place on the map, and I'm using Yootheme page builder to do that dynamically - every time I add a new article it automatically shows on the map.
I would like to be able to say this on the frontpage:
Currently, there is X locations on the map. (X is the number of articles in all subcategories).

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13322
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Number of articles in subcategories

Post by sozzled » Tue Jan 31, 2023 7:15 pm

You asked if it is "possible" to display the number of articles, in all categories. Yes, this is possible but this facility is not available out-of-the-box without making a custom feature.

I asked you where do you want to display this information. Do you want to display this information on the frontend or backend of your website? Do you want this information displayed at the top, bottom, side or in the middle of a page on your website?

How would you like this to appear? Would you like something like "There are 25 articles here" ???

Please explain what you would like. Anything is possible (but everything has a cost); the cost is your time (or money) or someone else's time to create what you would like. I can't give you more information if we don't know what you would like.

Back to you.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

Zheekan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Nov 01, 2014 6:42 pm

Re: Number of articles in subcategories

Post by Zheekan » Tue Jan 31, 2023 8:15 pm

I thought I explained it well, but here it is again:

I would like to be able to say this on the frontpage:
Currently, there is X locations on the map. (X is the number of articles in all subcategories).


The frontpage usually means the frontend of the website.
For the sake of this conversation, let's say I want it shown on the bottom of the page.

Thank you for your help.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13322
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Number of articles in subcategories

Post by sozzled » Tue Jan 31, 2023 8:21 pm

In that case (if this were my website), I would create a module, install it on the site, and assign it to a template position on the bottom of the page. As I wrote before, such a feature doesn't exist (as far as I'm aware). As I also wrote, it's possible to develop such a module but, as I also wrote, it will cost ... your time or your money.

If you want this feature—if it's important to you—you have to figure out the best way for you to develop a module. If you cannot write a module yourself, there are professional website developers who can do this for you. Only you can answer these questions.

Sure, I could build a module like this (if I wanted to) but I don't have any incentive or need for it.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

Zheekan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Nov 01, 2014 6:42 pm

Re: Number of articles in subcategories

Post by Zheekan » Tue Jan 31, 2023 8:37 pm

Well, Mr. Sozzled, thank you so much for your time!
I'm glad to now know that you're more than capable of building a module like that, but at the same time I'm so sad that I don't have the time to go through the other 13230 of your posts to see what other great advice you gave to the visitors of this forum.
Maybe one day... :'(

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13322
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Number of articles in subcategories

Post by sozzled » Tue Jan 31, 2023 8:48 pm

As I say, if this is important to you and you want a module to display "Currently, there are x locations on the map" at the bottom of your J! 3.x website, you can always post a request on the Professional Development Services forum here together with an offer of payment.

If this requirement is not important to you, please mark this topic as "resolved" and good luck with your website. :)
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

Zheekan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Nov 01, 2014 6:42 pm

Re: Number of articles in subcategories

Post by Zheekan » Tue Jan 31, 2023 9:01 pm

Agreed, but let's offer a short resume for future generations before we do that:

Joomla doesn't offer an option to show the number of articles in subcategories of a root category.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13322
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Number of articles in subcategories

Post by sozzled » Tue Jan 31, 2023 9:20 pm

Zheekan wrote:
Tue Jan 31, 2023 9:01 pm
Joomla doesn't offer an option to show the number of articles in subcategories of a root category.
I would rephrase your statement like this:

There is no facility in J! 3.x to display the total number of articles, from all categories, as a single line that reads "Currently, there are x locations on the map", appearing anywhere on the frontend of the website.

Obviously, you can find out how many articles you have on a J! website using SQL. For example:

1) To calculate the total number of articles—including published, unpublished, trashed and archived articles—the SQL query would be:

Code: Select all

SELECT COUNT(id) FROM xxxxx_content; 
where xxxxx is the table prefix used by your site.

2) To calculate the number of articles that are published on your site, the SQL query would be

Code: Select all

SELECT COUNT(id) FROM xxxxx_content WHERE state = "1";
3) To calculate the number of articles that are published or "archived", the the SQL query would be

Code: Select all

SELECT COUNT(id) FROM xxxxx_content WHERE (state = "1" OR state = "2");
Depending on what you want to display, you need to write a module that uses something like what I have written above. I can't teach you how to write a module on the forum; I can't give you step-by-step instructions. I can only give you the general idea.

The general idea is that you can't do this out of the box without writing PHP.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)


Post Reply

Return to “General Questions/New to Joomla! 3.x”