I know about the Devel Module's capability to generate random content (BUT almost no control over the data entered) and also about the D7 Devel script which is a possibility, but i'd like to have a module and not a script. The Dummy Content Module creates the content only upon installation, thats why it does not help me either cause i want to create it via a menu option like it is with the Devel Module.

I searched high and low but could not find a module that gives me that option, can anybody give me a hand here?


Creat Dummy Content with specific ranges for

  • date fields: e.g. between "now" and "now +10 day"
  • number fields: e.g. between 10 and 20 step 2
  • ...
  • 1
    Random data that you have "control over" is not random any more, so I think what you're looking for is at odds with Devel's intended use (of the base module at least). It looks pretty easy to extend, but you'll need to develop a module to do so
    – Clive
    Commented Dec 5, 2013 at 10:42
  • You are right, i am not looking for the random generator that the Devel Module has, i just mentioned it above to prevent the "Google it stupid" answers. I did indeed look into this problem but could not find a module that suits my needs. As i said, i was hoping not having to extend the module or writing my own, as i think this is a not so uncommon use case and it seemed likely that somebody else already did that...
    – Larzan
    Commented Dec 5, 2013 at 12:08
  • @Larzan if someone needs specific restrictions, it's not a general case anymore. I wouldn't hope to find anything ready-made for that.
    – Mołot
    Commented Dec 5, 2013 at 13:46
  • Hmm, you are right about that, but even in the Devel Module there is one restriction you can choose for the publication/authoring date. So i was wondering if there was something along those lines, just for the fields of a custom content type. I will give it some more time, and then start digging into the code myself i guess :|
    – Larzan
    Commented Dec 5, 2013 at 13:51

2 Answers 2


Quick solution that worked best for me in the end:

The solution i gave before was indeed the best one to have a general solution and use the mechanisms that were used in the devel module, but what worked best for me in the end was to just use the HOOK_node_presave to validate the nodes that were created by the devel module.

function MY_MODULE_node_presave($node) {
  // only do this for my_type, and only for nodes created by the devel module
  if ($node->type == 'MY_TYPE' && isset($node->devel_generate)) {
    // apply the limitations, e.g. use values between 2 and 8 in our field
    $node->field_my_field["und"][0]["value"] = mt_rand(2, 8);

In case a node of the type MY_TYPE is generated by the devel module (verified by checking the devel_generate property) we give the field field_my_field a value between 2 and 8. This is not possible with the devel module, but we can apply this custom restrictions here and modify the node before it is saved.

So the devel module will create the node as usual, but the function above will modify its values to our needs before it is being saved to the DB.

This has the desired effect although it is hard coded in our custom module, it does the trick.


As noone seems to be able to answer this one, i'll tell the tale of what i finally did:


I tried to get the hook_content_generate that is mentioned on a few webpages to work as it seems to be the best way to do it without writing a full fledged module, but it seems that this does just not exist (anymore?). So this was a cul de sac.

Then i saw mentioning of hook_devel_generate which seems to be kind of a semi-hook (not a real Drupal hook, but these functions get called by the devel_generate Module to actually create the data), but browsing through the module i saw that before calling the HOOK_devel_generate function, it looks for module include files of the type 'FIELDTYPE.devel_generate.inc' in its own folder, and then in the folder of the FIELDTYPE module to include them via module_load_include.
It has generation functions for 'file', 'image', 'taxonomy', 'number', 'text', 'comment', 'list'. So any function that one might create of the form FIELDTYPE_devel_generate will be overwritten by the functions included in those files. This is not very flexible and can't really be extended/overwritten, but thats how it is. When i find some time after finishing this project i will bring it up in their forum maybe they will agree to implement sth. more extendable in the future.


So there were two options that looked feasible albeit a bit "hacky"

  1. Implement our own version of the devel_generate
  2. Modify the current devel_generate to our needs

    1. Just customize the included functions
    2. Modify devel_generate to look for custom functions in other modules before loading its own

None of these aproaches are optimal, the best would be if devel_generate were to implement some hooks to call the generation functions, and not just this brute force inclusion of files.


I went with option 2.2 and patched my "devel_generate.fields.inc" and replaced this code i found at line 41.

// Include any support file that might exist for this field.
if (in_array($module, array('file', 'image', 'taxonomy', 'number', 'text', 'comment', 'list'))) {
  // devel_generate implements on behalf of core and special friends.
    module_load_include('inc', 'devel_generate', "$module.devel_generate");
else {
  module_load_include('inc', $module, "$module.devel_generate");
$function = $module . '_devel_generate';

with this one:

$function = $module . '_devel_generate';
// only load the devel_generate or the FILEDTYPES functions if no FIELDTYPE_devel_generate
// function has been defined elsewhere ($module is actually the name of the FIELDTYPE)
if (!function_exists($function)) { // ONLY if the function doesn't yet exist load the files
  // --- ORIGINAL code
  if (in_array($module, array('file', 'image', 'taxonomy', 'number', 'text', 'comment', 'list'))) {
    module_load_include('inc', 'devel_generate', "$module.devel_generate");
  else {
    module_load_include('inc', $module, "$module.devel_generate");
  // --- END ORIGINAL code
// We already initialized $function, so remove here..
// $function = $module . '_devel_generate';

So with this i can now define my own FIELDTYPE_devel_generate functions and they will have priority over the ones defined in the fieldtype itself and the ones of the devel_generate module. This way i could even control the content of each unique field by identifying it through its name ($field["field_name"]), to use field specific settings in my generation function;

I hope this will help others looking for sth. similar, so that they don't have to waste a whole day with research as i did.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.