I could not find any documentation on how to use Multiple Files for a Module's _views_data and _views_default_views functions.
My module has close to 20 Views that are defined in module_name.views.inc and module_name.views_default.inc. These files are now pushing 4000 lines and are very hard to maintain. I would like to split these files into two files for each View so they are easier to maintain.
The only method I've found for this is to use something like this in module_name.views_default.inc:
function module_name_views_default_views() {
$files = file_scan_directory(drupal_get_path('module', 'module_name'). '/views/default', '.inc');
foreach ($files as $filepath => $file) {
require $filepath;
if (isset($view)) {
$views[$view->name] = $view;
}
}
return $views;
}
I cannot find an example for module_name.views.inc, but something like this might work:
function module_name_views_data() {
$files = file_scan_directory(drupal_get_path('module', 'module_name'). '/views/data', '.inc');
foreach ($files as $filepath => $file) {
require $filepath;
}
return $data;
}
Is this the standard/best method to split these large files into smaller ones? If so, adding this to Advanced Help would be useful.
Comments
Comment #1
dawehnerThere is a good reason to split views default, because later is it much easier to update a single one.
But i don't see this advantage on views data, but here is a code snippet which would do the same
I'm not sure whether this works, but i hope so :)
Comment #2
merlinofchaos commentedYes, og and advanced forum use a method like this. Patches to the advanced help to document this would be welcome.
Comment #3
bendiy commentedThanks for the feedback. I'll look into option #1 and browser OG and Advanced Forum's code. I'll try and put together a patch to Advanced Help if time permits.
Comment #4
dawehnerCool!
Comment #5
esmerel commentedI'm not quite willing to close this yet, but..
Comment #6
esmerel commentedComment #7
merlinofchaos commentedJust won't fixing. THis issue is 2 years old.