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
So, how would you propose to do that? Where in the rest of the HTML would it go? And, without a function call, how would it get there? No, I am afraid that magic is not possible. Even the stuff in the header requires a function call, all be it one that is normally present.
I’ve not researched the technical details but I do know the capability exists. For example, I’m using Joomla to drive my website and I recently added an extension to allow comments to the articles. I did not need to modify my template’s php code to include a function that would enable comments. They just “magically†appeared on all articles. I know it’s not magic, and for sure the architecture behind Joomla is different than zenPhoto, but my point is, it can be done. With the little I know about the Joomla templates, there may well be a generic core function call that someone creating a template includes. The generic core function may cycle through all enabled extensions invoking them so that the extensions can do their magic. Something like this would enable users, which are not a technical as others, to take advantage of the plugin’s features. I should learn more about this as I want to create an extension in Joomla for zenPhoto.
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.
I've updated the Google Analytics plugin (v1.1) to use the latest coding practice suggested by Google. Now, the plugin will handle any errors that may occur during Google page tracking.
Go to http://www.moto-treks.com/zenPhoto/google-analytics-for-zenphoto.html to download.
Is this still working for anyone in v1.2.9? Just upgraded and doesn't seem to be working. Verified plugin is still there. I also tried to deactivate it and reactive the plugin and nothing. Trying on zenpage theme now and just manually added the google analytics code to the footer.php file and it's working fine for now
(edit)
Disregard that. Forgot it doesn't show the code if you're logged in as admin.
Google recently released updated tracking code for Google Analytics which allows for asynchronous tracking. I just updated the google analytics plugin to version 2.0 which takes advantage of the new capabilities.
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