0

I am writing software to generate an amount of couponcodes, the user has to be able to pick an algorithm that generates the codes.

I want to write a couple of algorithms and make them into plugins with the CTools Module. Depending on which algorithm the user has selected (through a settings form) that algorithm is set as the 'current algorithm to generate codes'.

when the user then chooses to generate an amount of codes (using the Batch API for this) the generate_code() function in the chosen plugin should be called.

I have been searching multiple days now for good tutorials or documentation on how to do this, but I can't seem to figure it out. I have gone through the 'ctools_example_plugins' code, and

Anybody who can help me out here? or has more information on plugins..

would be appreciated!

mzy
  • 1,754
  • 2
  • 20
  • 36

2 Answers2

1

I don't know anything about CTools plugins....

but it sounds like you could define your own hook function for the algorithm, and then have seperate modules to implement the distinct algorithms

see Can you Create your Own Hook in Drupal?

Community
  • 1
  • 1
Ben Hammond
  • 705
  • 1
  • 7
  • 20
  • so what you suggest is: 1. in codes.module I define hook_generate_code and have a settings form in which I choose how many couponcodes and with which Algorithm I want to generate codes, 2. I write multiple modules, one for each algorithm, each implementing the hook (algorithmX_generate_code) but then how do I set which algorithm/hook implementation I want to use? – Karel-Jan Misseghers Mar 21 '12 at 09:47
  • I tried this but had the problem that hooks can't seem to be used in .inc files.. – Karel-Jan Misseghers Apr 12 '12 at 14:16
0

Fixed it, used this Great example:

http://www.programmingtuts.com/tutorial/drupal/yuriy-gerasimov-ctools-plugins-system.htm

(presentation on same subject here: http://www.slideshare.net/ygerasimov/drupal-camp-donetsk-c-tools )