I'd find it very useful to be able to use hook_simpleads_order() to order ads contextually, based on the node ID, and possibly other criteria. I'm willing to write the code for the diff, but first I'd like to know if there is interest in adding this type of a feature to simpleads.

Adding this functionality is as simple as alter the current simpleads_order hook to allow for one more parameter - e.g. the nid. Hooking into the system to access the new parameter would then be a simple call to drupal_ad_js(). For example, to give your custom ordering function access to the nid of the node requesting ads, you might use something like this:

drupal_add_js(array('couponsAndOffers_simpleads_menu' => array('simpleads_custom_crit' => arg(1))), 'setting');}

simpleads.js would detect the simpleads_custom_crit value and include it as the final parameter to the simpleads/load menu item. The simpleads_order (or simpleads_order_custom) hook would then have access to the (e.g.) nid of the page requesting the ads.

A modification of this nature would dramatically increase the power and flexibility of the simpleads ordering API.

Comments

jbulcher’s picture

Here's a pretty straightforward patch, including updates to the API. The patch is working for me.

jbulcher’s picture

Status: Active » Needs review
jbulcher’s picture

Issue summary: View changes

refine my idea

minnur’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)