Our installation will be hosting a couple of journals.
We’ll want the best way to get a quick count (total for all journals) of the following, to display on our homepage to visitors.
- total journals hosted.
- total articles (submitted/published).
etc. (we’d probably figure out the rest, if we can get the first two).
I checked the Stats & Reports page, JournalStatisticsDAO.inc.php, and StatisticsHandler.inc.php. It seems, I think (I might be 100% wrong on this one), that what’s being implemented is just for a single journal (not a net sum of all the journals).
please how do we go about getting these numbers from the database?
…or, is there a plugin already handling this, that we should know of?
Those numbers would be easy and quick to fetch from the database with a couple of simple queries:
SELECT COUNT(*) FROM journals;
SELECT COUNT(*) FROM articles; # For total article count
SELECT COUNT(*) FROM published_articles; # For published article count (ROUGHLY, depending on your publishing process)
I would suggest adding those queries to JournalStatisticsDAO, and adding a bit of code e.g. to
pages/index/IndexHandler.inc.php to assign the results to the homepage template. Then, somewhere in
templates/index/, add the mark-up to display the numbers.
Public Knowledge Project Team
Thank you @asmecher for the detailed reply. I’ll give this a shot asap.
Thank you @asmecher! what you suggested worked. I created small methods in JournalStatisticsDAO to handle the queries, and assigned my variables in the display method of the template manager (I finally decided to display all the information site-wide in footer.tpl), like so:
$allJournalStatsDAO =& DAORegistry::getDAO('JournalStatisticsDAO');
everything works fine, for now