I am trying to add custom no result behaviour to a view. I have many pages with view panes in them. Sometimes if no results are available, I would like to be able to display a 404. This is not an option when it's a view pane. I would like to do this in a reusable way where if the view pane has that custom option then this happens.

I can hard code this stuff on one of views hook, but ideally I want to be able to configure such behavior.

1 Answer 1


This is not an option in views panes because a 404 should be returned by the page_callback handler, which in this case is the panel that is holding the pane.

Option 1, see if this module works views404, but I have not used it so I do not know for sure.

Option 2, use drupal_not_found(), though I have not tried this in a panel. Or if you are using contextual filters try this.

Option 3, stop using panels and use view page with Bean and Context and theme regions and a bunch of other things. This way the page_callback is being handled by the view, so the view has the authority to return a 404 instead of theming the frame and other blocks and presenting those. Downside is you have to restructure the whole site so you probably dont want that.

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.