|
Creating an Openads 2.0 plugin is pretty easy.
Yeah, this isn't exactly the most current technology article ever written. Everyone is jumping over the new Openads 2.3 Beta and I'm writing about the 'soon-to-be-passé' Openads 2.0. Oh well, maybe someone needs a custom reporting plugin for Openads 2.0. If you do you're in luck.
First, log into your admin UI for Openads. This should be easy enough. Click on the 'Reports' tab. If you do a View Source on this page, then do a Find on "selection", you'll see a dropdown. Each of the option elements get their unique value from files that are placed in your <openads root>/admin/report-plugins directory. You can take a look at these files and use them as examples of what you'd like to accomplish. I copied campaignhistory.plugin.php to campaignhistoryMonthly.plugin.php. As long as the first part of the name (before the first dot) is unique, you'll be fine. Next, you'll need to edit the file you created. Here's the bargain basement steps for getting this plugin to run: - change the value of $plugin_info_function to something unique. This value has to point to whatever function is called when the plugin is run. For the plugin I created, I set it to "Plugin_CampaignMonthlyInfo".
- If you copied an existing plugin, the function to be run is located just below the line that sets $plugin_info_function. Make sure you rename this function to whatever you set the value of $plugin_info_function.
- In the array $plugininfo that is created in your public function, there are a bunch of values you can set. I just reset plugin-author to myself, plugin-name to "Campaign Monthly History". I'm sure there's a bunch you can do here but you can tinker with that yourself. I also set plugin-execute to a unique function name that's see farther down in the code. Since this function is private, you might be able to get away with leaving that array variable and function name alone. Sloppy but you might be able to do it. I didn't try that. In my case I set plugin-execute to Plugin_CampaignMonthlyExecute
- Of course that now means you need a function, Plugin_CampaignMonthlyExecute or whatever you came up with. Scroll down the code and you should see a comment block, "Private plugin function". Just under that is the function you need to rename to match whatever you set plugin-execute to. Go ahead, rename it.
- From here you should have a working plugin already that can be called from the dropdown under the reports tab. But you didn't just want to duplicate the plugin, right? From here you're going to have to read the code and tinker until you get what you want. In my case I just changed the main queries to
SELECT DATE_FORMAT(t_stamp, '%m') as date_order, DATE_FORMAT(t_stamp, '%M') as date_formatted, count(bannerid) as adviews FROM ".$phpAds_config['tbl_adviews']." WHERE bannerid IN (".implode(', ', $bannerids).") GROUP BY date_formatted ORDER BY date_order
Not rocket science, but it generated a report that helped someone in sales. - Keep typing until the plugin does what you need it to.
Good luck! |