Extension, Module

Developer
Supported

Audit

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Mark J. Reeves

     

You must be logged in to post.

Template tags for Audit

General

Mark J. Reeves
Developer
Mark J. Reeves

I’ve been asked twice now whether Audit will support template tags to output log entries. Most recently on Twitter:

does your new Audit addon provide template tags to show the logged data to templates within exp:channel:entries

My thoughts:

1. This would be an Audit Pro feature, as Audit simply logs activity and provides a screen to read those logs.

2. Audit has a really simple table structure and so this can be easily done with an exp:query tag (if you’ve enabled the Query Module).

If you want to see the log entries for a given channel entry, it would be:

{exp:query sql="Select * from exp_audit_log where (item_type='entry_update' or item_type='new_entry') and item_id=40 order by timestamp desc}{/exp:query} 

Where 40 is the entry ID.

You can see what fields are available via Tools > Data > SQL Manager, and use the field names as template tags for those values.

3. In thinking about offering an output tag that would accomplish the same thing, I’m thinking there’s an opportunity for an input tag as well. Something like:

{exp:audit_pro:log item_id="" item_type="" item_title=""

Allowing you to create your own log entries from templates.

That gets a bit tricky, as item types are currently a predefined list that drive certain rules and labels, but would enable Audit to be used for additional logging via template code.

4. I’m not sure template tags are something that every user of Audit Pro would find value in - It’s really meant to extend the Control Panel - so these might find themselves in a plugin with a nominal cost.

In any case, template tags do merit some thought, but would not be part of the initial Audit Pro release, which should happen this week. The SQL presented here, using the Query Module, will output any matches based on an entry being viewed.

Mark

Mark J. Reeves
# 1
Developer
Mark J. Reeves

This post has moved to the Audit Pro forum.