0

My (Drupal 7) site has a search which uses two blocks - one for entering the criteria and one for the results.

(For brevity, I won't explain in detail why I need two blocks but it's basically because I'm doing a drop-down search a bit like this approach. Suffice to say that I can't do it all in one block.)

The search is at mysite.com/contact-us. I've got a context rule which shows the criteria block in the sidebar when the contact-us URL path matches.

I want the results block to appear on the same page as the criteria block, appearing in its place. Therefore, I've got a URL alias of contact-us/find, which points to contact-us. My context rules say that if the path is contact-us/find, the results block should be shown. (The alias was set up via the UI, i.e. Configuration > URL aliases)

So both contact-us and contact-us/find show the Contact Us page, but there are different Context rules and so different blocks are shown in the sidebar.

That's the theory anyway. Here's what happens in practice:

  1. I browse to mysite.com/contact-us. I see the criteria block.
  2. I fill in the search criteria
  3. I am taken to e.g. mysite.com/contact-us/find?property=35 (the querystring provides an ID which the results view uses). I see the results block in the sidebar. So far, so good!
  4. However, if I then go back to mysite.com/contact-us (e.g. to search again), I still see the results block and not the criteria one! And it thinks there are no results as I no longer have the querystring.

If I clear the cache, all is well again - I see the correct blocks. But I need a solution which doesn't require a cache clear - that's not something my users will be doing!

I presume that I'm running into problems because both contact-us and contact-us/find are actually the same node, and so Context can't accurately differentiate between them unless the cache is empty, but I'm not sure.

Any suggestions how I could resolve this one? Could I have a different type of rule specifying when the blocks should appear? Or something else? I'm all out of ideas!

0

In the end, we changed the whole approach here, and made the jump menu load the new block with AJAX. (I wasn't the person who developed the new way of doing this, so I can't provide much more detail, I'm afraid.) This was a lot less buggy than my original approach!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.