Hi. I'm trying to work with the context module and 403/404 pages. Basically I want to specify a context for 403/404 pages to allow the display of a few different blocks. I am using the http://drupal.org/project/blocks404 module as well so I can show blocks on those pages.
My 403 page is currently set via the LoginToboggan module to a path of toboggan/denied. This is a new path created via hook_menu in the toboggan module to present a login page. The way it works is if a user visits a 403 page (let's say they want a node called /pub/contact but it requires authentication), login toboggan wakes up, gives them a login form, and allows them to continue on to that inside page after logon.
If I set a context condition of 'path' pointed to toboggan/denied and a reaction of blocks to be displayed, it works fine when I am actually on the path of http://mysite/toboggan/denied. My blocks are displayed correctly.
However, when I visit an actual 403 page that is redirected that logon form - such as http://mysite/pub/contact - I do get the toboggan logon form but the blocks are not there. The context module isn't picking up on the fact that it is at a 403 page that was redirected.
I'm not sure if that made sense or not. Basically I'm looking for a way to create a context for 403/404 pages so I can have certain actions take place, such as the display of blocks.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 814382_context_path_plugin.patch | 929 bytes | hefox |
Comments
Comment #1
rjbrown99 commentedReplying to my own post. Here's what I am doing for 404 messages (I describe 403 above).
1. Install http://drupal.org/project/blocks404
2. Apply patch from here so headers work properly: #601420: blocks don't display on 404 pages under Pressflow
3. Install http://drupal.org/project/customerror
4. Configure appropriate error message on customerror admin page /admin/settings/customerror
5. Set /admin/settings/error-reporting for the 404 page to point to customerror/404
6. Create a context:
* Require all conditions: enabled
* Condition: path, customerror/404
* Condition: user role, anonymous user
* Reaction: block, whatever blocks you want
This isn't working as expected. The blocks don't show up.
If I go to the actual Drupal blocks page, take the block in question, configure it to only show for anonymous users and only on the customerror/404 path, and then move it to the region it works.
Comment #2
yhahn commentedComment #3
yhahn commentedI've looked into this -- the problem is that the 404/403 page status is determined by Drupal after
hook_init()has run which is where Context checks the path condition.One possible fix for this would be to move the path condition (and generally, other condition checks) into later in the page load. As this would be a major API change I am postponing consideration of this until after 3.x stable.
Comment #4
steven jones commentedNew context condition that looks at the HTTP response code needed?
Comment #5
thijsvdanker commentedsubscribe
Comment #6
snufkin commentedShould this be a patch to context or implemented in contrib?
Comment #7
hefox commentedA first step in this seems to be to make sure context shows for the right path if the page callback changes the current active path; this patch does this
http://drupal.org/project/context_error provides a 403/404 error handling condition
Currently context shows blocks from original path on 403/404 :(.
Comment #8
pawel_r commented+1
Comment #9
rolodmonkey commentedSince Drupal 6 is no longer supported, I am closing this issue.