I’ve just created my first plugin for zenPhoto. Go to
http://www.moto-treks.com/zenPhoto/google-analytics-for-zenphoto.html to download. This plugin started its life as the google maps plugin.
I had been modifying the core code to insert the google analytics js but with the last update to zenPhoto I decided I’d just create a plugin to handle the majority of the work. Now all that’s needed is to add the function call to your template files.
I searched for a while on this site and reviewed the zenPhoto code but I didn’t find a way to write a plugin that would insert html code without needed to modify the template files to include a function supplied by the plugin. I saw the function addPluginScript but this only adds scripts to the header section of a webpage.
Does anyone know if it’s possible to write a plugin that will output html without using a function call within a template?
Enjoy!
Jeff
Comments
I really like zenPhoto and you guys are doing a great job but from what I’ve seen in zenPhoto this type of architecture does not exist. My suggestion to keep it in the back of your mind was because I imagine this is not a simple change to zenPhoto. At a minimum, zenPhoto would need to keep a collection of plugins which extend the HTML. These plugins would need to inherit a class structure to implement a known interface. A new core template function could then invoke each plugin in the collection. Yes, any template wanting to be plugin friendly would need to be modified but that would only need to be done once.
Anyway, just an idea.
Go to http://www.moto-treks.com/zenPhoto/google-analytics-for-zenphoto.html to download.
(edit)
Disregard that. Forgot it doesn't show the code if you're logged in as admin.
The best thing about version 2.0, is that you don't need to modify a template to insert the tracking code. Because the communication with google is done asynchronously, the tracking code can be placed anywhere in your template. Before, it was suggested to be placed near the bottom of your page. With the asynchronous interface, the tracking code should be placed near the beginning of the page. zenPhoto (v 1.3.1) provides an interface that enables plugins to place code in the header section. This upgrade takes advantage of this interface and the google asynchronous capabilities to insert the tracking code in the header section of you page.
What this all means is you can install this plugin, use any template you want, and always have google analytics tracking your code.
The upgrade is easy too, just replace the google_analytics.php file in the zp-core/zp-extensions directory and you're done. You don't even need to remove the old code in you're template for the version 1.1 plugin.
As a side note, I noticed that in a future version of zenPhoto (1.3.2 maybe) a new enhancement to the plugin interface will enable code to be placed at various locations, like at the beginning of the body section. When this enhancement is available, I'll provide an update which takes advantage of these capabilities.
Oh, plugin can be downloaded at http://www.moto-treks.com/extras/file-download/view.download/6/6
enjoy,
Jeff
I found myself with a few free hours today so I updated my site as well as worked on this plugin. Now, thanks to the 1.4, the Google Analytics plugin supports the theme filter methodology. Meaning, as long as your theme supports new 1.4 capabilities (I had to modify my theme too) all you need to do is add the Google analytics plugin to you plugin directory.
I'll test my modifications for a few days an then publish my update.
Jeff
Everything working great.
The update takes advantage of the new ‘theme_body_open’ filter in 1.4. What this means is that, as long as your template supports the zp_apply_filter methods, you don’t need to modify you template to use Google Analytics for zenPhoto.
I’ve also modified it so that you can install the plugin outside of the zp-core directory to ease zenPhoto updates.
As always if you find a problem leave me a comment on the download page - http://www.moto-treks.com/software/22-google-analytics-for-zenphoto
enjoy
Anyway, it was just a suggestion - didn't want you to have to chance links every time I'm a little lazy ;-)
http://www.moto-treks.com/software/22-google-analytics-for-zenphoto