I am thinking about writing a small module for a quite special case and I would like to get some hints to point me in the right direction. The case is that I have a list of 'codes' that I need to add to a node in this way:
<img src="http://example.com/<CODE>" width="1" height="1" alt="" />
The code is unique for every node, but not every node necessarily has a code. Additionally, the list of new available codes must be downloaded every once in a while.
The perfect world: The list of up to 20 new codes is downloaded every once in a while and added to the database through a web interface. In the node edit form, the user has the chance to activate an option widget to add one of the available and unused codes. The code is then inserted into the node on the theme layer. Any ideas, how that could be accomplished?
Ideas I've had:
- Add a simple text field and copy/paste the code there from a manually maintained list of codes.
- Somehow feed a database table with the codes and offer them as a selection in the node edit form. Only codes that haven't been used before can be selected.
Views integration would be appreciated, too. That's why I have been thinking of a solution somehow connected to CCK.
Any suggestions?
Comments
Try Here
You can discuss high level project requirements here:
http://groups.drupal.org/contributed-module-ideas
Ok, I managed to create a
Ok, I managed to create a small module that basically does what I want it to do:
- It provides a form to enter new codes
- It allows to select a CCK select list field to be used for the codes
- It adds allowed values to that field to select an available code
- It disables the select list once a code has been selected
- It provides a formatter for the CCK field to display the code
What I couldn't do was to provide the CCK field automatically. So far, the user has to create a CCK select list field, then choose it in the module's settings and then assign the custom formatter to it. I would like to have the module provide a CCK field so that those steps aren't necessary. Any hints on that?
Here's my module:
metis.info
metis.install
metis.module
SQL query all right?
I'd love to use your module, but it fails to offer the codes when creating or editing a page. The only option then is "- None -". I have installed the module, successfully added codes (confirmed by looking in the raw SQL database), set up a CCK field, selected it in the metis admin page, and set the field display mode to the metis pixel...
Any clues? Are you still working on the module? Maybe there is an updated version?
just to add to this: If I
just to add to this: If I change the field type to simple text field and enter the code manually, it works: the pixel gets included all right, and the field is grayed out when I edit again (since one metis pixel should only be used once). It would be marvellous, however, if the other functionality would also work: that I can store a list of METIS codes from which one code gets chosen whenever a page is first created. This code should then be fixed on this node and removed from the list of codes (so that it won't be chosen a second time)... It seems like metis_form_alter should do the trick, but doesn't...
once more: it only works,
once more: it only works, however, if the cck field is still set as the metis field in the admin pages (which is only possible while it is still a select box). Workflow: create metis field as select box, pick it in the metis admin pages, then change field type to simple text to be able to manually enter codes...
Basic module
Hi rsmr,
please excuse that it took me so long. I haven't been working on the module lately but at least I have a version that works more or less on on clean install. I will send it to you since I can't attach it here.