[dokuwiki] Re: Google Analytics plugin

Terence J. Grant wrote:

Hey guys, new plugin:

http://tatewake.com/wiki/projects:google_analytics_for_dokuwiki

May be of some interest to devers since it uses the concept of "plugin
that exports code for use in template", thought it's not as simple as
a one line "if fn exists call fn" like I had hoped, but close enough:

<?php
if (file_exists(DOKU_PLUGIN.'googleanalytics/code.php'))
include_once(DOKU_PLUGIN.'googleanalytics/code.php');
if (function_exists('ga_google_analytics_code')) ga_google_analytics_code();
?>


A simpler and neater solution maybe to use a custom event and an action plugin

E.g.

you make a plugin to handle "TPL_NONE_GOOGLEANALYTICS" event. The event handling mechanism will load the code associated with the plugin if its there.

Any template wishing to utilize the plugin include the line

$data = null;
trigger_event('TPL_NONE_GOOGLEANALYTICS',$data);

If a template were to trigger the event but not have the plugin the event will effectively be ignored - ie, no confusing errors generated.

Cheers,

Chris








-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: