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

PA robot’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 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.

PA robot’s picture

We 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.

basvanderheijden’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
basvanderheijden’s picture

Issue summary: View changes
basvanderheijden’s picture

Issue summary: View changes
dahousecat’s picture

Issue summary: View changes

Changed the git clone command to the public path.

dahousecat’s picture

Usability 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:

  • Users Override View (my custom view)
  • Content Override View (my custom view)
  • Recent comments
  • Tracker
  • Archive
  • Front page
  • Glossary
  • Redirects
  • Backlinks
  • Taxonomy term
  • BLANK (value was top_content - this was created by the fivestar module)

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 think the documentation should point out that it is not possible to override built in core views as at first I did think that this was the main point of the module.
  • The view created by the fivestar module had a value but not a name (human_name) so there was a blank item in the select box on the config page. In this instance should use the value as the label.
  • Maybe it would be a good idea to link to the view list page (/admin/structure/views) from your modules config page as some view names can be a bit cryptic.

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.

joshi.rohit100’s picture

In 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()

joshi.rohit100’s picture

Status: Needs review » Needs work
basvanderheijden’s picture

Thanks 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().

basvanderheijden’s picture

Status: Needs work » Needs review
joachim’s picture

Status: Needs review » Needs work
Issue tags: -#views

- 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().

I 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?

basvanderheijden’s picture

The 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.

basvanderheijden’s picture

Status: Needs work » Needs review
basvanderheijden’s picture

Updated project page to better reflect purpose & inner workings of this module.

joachim’s picture

Right, 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.

mpdonadio’s picture

Status: Needs review » Reviewed & tested by the community

Automated 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.

joachim’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, 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:

Make changes to your site using the normal Drupal UI. For example, edit a View the change it's title or which fields are displayed.
At admin/structure/features, notice the original feature is marked "Overridden". Click "Create Feature" to create a new feature.
Select "Features Overrides" from the Edit components drop-down selector.
Check the box next to the components you wish to save changes to (such as the View).
Click Download to download your new "override" feature.
Install and enable the new "override" feature just as you would with any other feature/module. Notice that nothing is marked as "overridden" anymore.

Hence this module duplicates existing module functionality.

basvanderheijden’s picture

Joachim, 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.

basvanderheijden’s picture

Status: Needs work » Reviewed & tested by the community
basvanderheijden’s picture

I updated the dependencies (added ctools) and concatenated strings in views_override.admin.inc instead of using sprintf.

klausi’s picture

Issue summary: View changes
klausi’s picture

Status: Reviewed & tested by the community » Fixed

Review of the 7.x-1.x branch:

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    FILE: /home/klausi/pareview_temp/views/views_override.views_default.inc
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     5 | ERROR | Doc comment short description must end with a full stop
    --------------------------------------------------------------------------------
    

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:

  • the project page should mention differences to existing approaches mentioned by joachim like features_override.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

avpaderno’s picture