I am attempting to gather as much interesting metadata as possible to display for readers of an EE site I'm developing and am looking for guidance on methods (or indeed the feasibility) of computing specific bits of this metadata in a scalable way.

EE allows for quite a few bits of data to be gathered and displayed natively, for example post totals and dates, comment totals and dates, tag totals (via a plugin), etc. However I'm specifically interested in methods to count and display totals for data like number of words, images, videos, or audio files, not only included within individual posts but cumulatively across a channel, as well as an entire site.

These totals would be displayed contextually depending on where they were accessed.

So for example search results would display the number of words/images/etc contained in individual posts, while a channel's "About" page would display totals for that channel, and the site's "About" page would display site-wide totals. I'm not clear on the best approach or indeed whether this is even really feasible.

I've pondered:

  • Entering these numbers in custom fields on a per-post basis, but am not clear on how they'd then be added together or output for channel and site-wide totals.
  • Using PHP's "count" method, but am not very familiar with PHP so unsure of it's appropriate.
  • Using some mySql method to query the database, again unfamiliar and unsure.
  • Utilizing the ExpressionEngine "Query Module" somehow.
  • Using some Jquery plug-in to do the counting individually and then adding after the fact.

It may be that the counting of words, images, video, and audio files and the scalability are different questions all together but the truth is I'm not sure what avenue would even be best to explore at this point.

This is not a mission-critical question but any and all suggestions are appreciated. In fact suggestions regarding any bits of metadata (with the exception of member-related data) that is retrievable and displayable on the front end, beyond what I've laid out here, would interest me. Thanks.

1 Answer 1


Probably not the specific implementation answer you want, but speaking generally, the sane way to do this is if you really feel the need is to store/cache this information per entry on entry publish/update, as:

  • It ain't gonna change unless an entry save happens
  • It's potentially computationally expensive to generate
  • It's probably not the end of the world if these values are a little bit off. (See the slight variations in SX meta scores in the users tab vs viewing a user's profile)

Then when you need the summary data (for your "about" section or similar) sum your per-entry values and again cache it aggressively.

As for calculating the per entry data, you'd need a custom extension, though it wouldn't need to be very complex. The hook you probably want is entry_submission_absolute_end

For storage/retrieval I'd suggest a separate table managed via a custom module - you don't need the overhead of storing this in channel data, and you'll get far better performance by just storing what you need against entry_id's.

Text should be relatively straightforward, though images/video/audio etc are going to be pretty hard to decouple from their fieldtype implementation (will/are you using Matrix, Channel Images etc etc etc).

Oh and I really wouldn't even think about doing this kind of thing with jQuery. Using JavaScript for string manipulation/iteration when you've got the option of doing it server side is not a good idea in performance terms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.