Plugin Name: Chitika Keywords

Plugin URL: www.goplayav.com/customizing-chitika/

Description: Allows the dynamic substitution of the Chitika query array (keywords used for selecting ads) by using the post's categories

Version: 1.0

Author: Chris Howard

Author URI: www.qwertyrash.com


INSTALLATION

Copy this file to your plugins folder and activate throught the admin plugins panel.


USING CHITKA KEYWORDS PLUGIN

Replace the keyword list in the Chitika ad code with <?php chitika_keywords(method, default_words, idlist, kwdlist); ?>. See the example below.


The plugin takes four parameters, all of which are required. For those not used, they must still be indicated, so use the null value by supplying two single quotes. eg <?php chitika_keywords('categories', '', '', ''); ?>


The parameters are:


method which can have values of categories, categoryid, primarycategory. Th descriptions of these values are:

categories: Uses all the categories for the current post as the keywords. This requires only the first argument

primarycategory: Uses the first listed category for the post as the keywords

categoryid: Looks for the category ID in the posts categories, if found, uses the corresponding keywords in kwdlist as the keywords.


default_words which are the keywords to use when no matches are found. This would normally be the same as your normal Chitika keyword list and takes the form '"keyword1","keyword2","keyword3",...'


idlist is a list of category IDs to look for when method is categoryid. This takes the format 'idno1, idno2, idno3,...'


kwdlist is a list of titles for each of the category IDs in idlist. This must contain the same number of elements as idlist. kwdlist takes the form:

'"keywordno1","keywordno2","keywordno3",...' If you want more thank one keyword for an ID, separate them with a semi-colon. eg '"PSP;Playstation Portable"'



EXAMPLES (including the Chitika ch_queries code). I've colored the four parameters differently to make it more readable:


Here is an example of the categoryid method, (which is the most complex method to use):

var ch_queries = new Array(<?php chitika_keywords('categoryid', '"ipod", "playstation portable", "portable video", "gameboy advance", "nintendo ds", "MP3 Player", "Archos", "MP3 Player", "Creative Zen"', '100,101,99,102,103,105,112,104','"iPod nano","iPod shuffle","ipod","iRiver U10","Archos AV700","Archos Gmini 402","Creative Zen Vision","PSP;Playstation Portable"') ?>);


Example of category method:

var ch_queries = new Array(<?php chitika_keywords('category', '"ipod", "playstation portable", "portable video", "gameboy advance", "nintendo ds", "MP3 Player", "Archos", "MP3 Player", "Creative Zen"', '', '') ?>);


Example of primarycategory method:

var ch_queries = new Array(<?php chitika_keywords('primarycategory', '"ipod", "playstation portable", "portable video", "gameboy advance", "nintendo ds", "MP3 Player", "Archos", "MP3 Player", "Creative Zen"', '', '') ?>);


Note I always fill in the default_words parameter. Just in case.


TROUBLESHOOTING:

1) It is important that you use the CORRECT QUOTES - single or double. So check that first if things seem not to be working.

2) Check the SPELLING of the method you are using is correct. If you misspell it, the plugin will use the default_words parameter as the keywords. For this reason, it is advisable, that you always enter values into the default_words parameter

3) Any errors in the Chitika code will cause unexpected results - such as subsqequent ads on a page, using previous ad parameters. Make sure you make no changes to your Chitika code except for the replacement of the keywords with the plugin code.

4) This plugin will only work in THE LOOP. 


FUTURE:

1) Enable it to work outside the loop so that ads in sidebars will also be able to access a post's categories.

2) Add a parameter for sidebars to use the current category on a category page (this would be obsolete if I ever get #1 working)



CHANGELOG:

1.0 First public release




Copyright © 2005 http://www.qwertyrash.com/ (email : developer@qwertyrash.com)


This program is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.


This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.


You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA