This module extends the default views behaviour by giving the user a chance to override built-in views with his/her custom views.
This is especially handy for modules that come with built-in views, i.e. Commerce Backoffice.
Or to override views like the content overview page at admin/content/node
Project sandbox link: https://drupal.org/sandbox/basvanderheijden/2235797
Git checkout:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/basvanderheijden/2235797.git views_override
Installation:
- Download the Views module, enable it and configure to your needs.
- Download the Views Override module, enable it and visit Configuration -> System -> Views Override (/admin/config/system/views-override)
- Specify which views you want to override, and save the configuration.
- You are ready to roll!
How this module works:
When overriding a view via the Admin UI, this module basically does two things for you:
- 1. it disables the original view via code (via the views_default_views_alter() hook),
- 2. it alters the load callback for the view (used by views_get_view() function) to load your overridden view instead of the original view every time the view is requested via views_get_view().
Using code instead of the UI to override views:
Because this module uses the variable store to configure your views overrides, it's really simple to define your views overrides in code,
To do so, add the following structure to your settings.php file, substituting your own view (machine) names:
$conf['views_override'] = array(
// The original view // The overriden view
'commerce_backoffice_orders' => 'my_awesome_custom_view',
'content_overview' => 'my_other_awesome_view',
);
Reviews of other projects:
SOLR Google Like
Most Viewed per Content Type
Menu block ignored links
Comments
Comment #1
PA robot commentedProject 1: https://drupal.org/node/2235863
Project 2: https://drupal.org/node/2030715
As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).
If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
basvanderheijden commentedComment #4
basvanderheijden commentedComment #5
basvanderheijden commentedComment #6
dahousecat commentedChanged the git clone command to the public path.
Comment #7
dahousecat commentedUsability Review
The module installed fine so I went ahead to set up some views to override.
I created one view to override the page at /admin/people and one view to to override the page at /admin/content.
I then went to the config page but was not sure what view to select in the default view select. The options were:
None of these seem options seemed to relate to the page at /admin/people but I thought the Archive view could relate to /admin/content so set that view to be overridden. Checked /admin/content but nothing had changed.
Next I created a custom taxonomy term view to override the view at /admin/structure/taxonomy/TERM_NAME. I set up the override but again could not see any change.
I then realised that the views I was trying to override were all disabled views that could be seen in the list at /admin/structure/views, and there was not option to override the core views such as /admin/people and /admin/content.
I then tried to override one of the custom views I had made with another and this worked perfectly.
My feedback would be:
I don't think any of these are major issue but could be something to consider.
Code Review
I could not find any errors.
I'll leave this as 'needs review' for the moment so someone else can take a look too.
Comment #8
joshi.rohit100In views_override.views_default.inc file, you have mentioned the wrong hook in comment.
It is hook_views_default_views_alter(), not hook_default_views_alter()
Comment #9
joshi.rohit100Comment #10
basvanderheijden commentedThanks joshi.rohit100 and dahousecat for reviewing.
- Added an extra disclaimer which states that this module is not intended for overriding core Drupal pages. Its only purpose is to override existing views, created by the views module or defined in code.
- Included the machine name AND the human name of the view in the admin page, as suggested by dahousecat.
- Updated wrong hook comment to hook_views_default_views_alter().
Comment #11
basvanderheijden commentedComment #12
joachim commentedI don't really understand how this works.
Are the replacement views in code, or in the database?
If the former, is this functionality not already covered by https://drupal.org/project/features_override?
If the latter, surely Views lets you do this already?
Comment #13
basvanderheijden commentedThe replacement views can be in code or in database.
The only thing this module really does, is take the view that would originally be loaded in by views_get_view and replace it by another view of your choice.
This is especially handy for modules that come with built-in views (and possibly load the view at some places programatically via views_get_view).
So if I issue view_get_view('commerce_backoffice_orders'), or view_get_view_results('commerce_backoffice_orders') and you setup this module so that my_custom_view is overriding commerce_backoffice_orders, it will be shown/returned instead of the original view in all instances. This way, you will not have to hack/preprocess/patch the providing module of the original view.
Comment #14
basvanderheijden commentedComment #15
basvanderheijden commentedUpdated project page to better reflect purpose & inner workings of this module.
Comment #16
joachim commentedRight, but I can edit commerce_backoffice_orders in the UI, save it, and then have my DB copy override the version of commerce_backoffice_orders that the module provides in code.
Or, I can use Features Override to have my changes to commerce_backoffice_orders be in code.
Comment #17
mpdonadioAutomated Review
No issues.
Project Checklist
You have two project applications. The other is closed, so I assume this is the only one you need to proceed with.
Otherwise OK.
Code Walkthrough
Why is the config form in admin/config/system/views-overide? Wouldn't a tab in admin/structure/views be better?
In views_override_admin_form(), you just need !empty($v->human_name) and not the isset().
views_override_admin_form() You are using sprintf? Just concatenate the strings.
You are explicitly using ctools functionality, so you should declare it as a dependency in the .info.
_views_override_load_view() could use some more comments as to what is going on.
Use of docblocks to Drupal standard could be a little better.
I think you shouldn't be able to select a disabled view.
Conclusion
I don't see any blocking issues. I do see fail to see a real need for this, but that isn't for me to judge. In addition, everything looks like it is done in the right way to accomplish this task, so I am setting RTBC.
Comment #18
joachim commentedSorry, but I have to disagree. This feature is already covered by https://drupal.org/project/features_override:
The project page for that clearly shows an example of overriding a view in code:
Hence this module duplicates existing module functionality.
Comment #19
basvanderheijden commentedJoachim, I have to disagree. I tried your workflow, but I think my module offers a faster, easier and more clean solution.
Because: if you override the view via the features override, you have to actually alter the original view and save it in a feature. Then, if you upgrade the providing module (of the original view), problems arise and you can't see clearly what the changes are.
My module has the same result, but you can still keep the original view and specify another (possibly duplicated view) as a replacement.
Comment #20
basvanderheijden commentedComment #21
basvanderheijden commentedI updated the dependencies (added ctools) and concatenated strings in views_override.admin.inc instead of using sprintf.
Comment #22
klausiComment #23
klausiReview of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
But otherwise looks good to me, so ...
Thanks for your contribution, basvanderheijden!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #25
avpaderno