Hi, I'm using Drupal 6.6 with Views 6.x-25.

My question is related to inheriting views exposed filter queries from url to display content in a views block.

I'm having two exposed filters one of which is a text field to search contents based on keywords to be put by the users and the other exposed filter is a drop down menu of taxonomy categories.

I have created a default view, a page and a block.

The url path for the page is something like:
http://www.mywebsite.com/search_keywords?keys=science+books&tid_op=or&tid=5

As you can see from the url, "search_keywords" is the name of the view.

Also I'm not using any arguments for the default and the page section.

While the views page works wonderfully, the views block placed on the same page, with the same filter settings displays all results starting from the first term id, on the block display section. (on the right side bar of the same views page), irrespective of the search query.

From views documentation, it appears that I need to put some php argument code for the block section to enable it to display content based on the search query and exposed filters.

Since I'm not using any argument for the views default or views page and my url path is stated as above my issue here is to convert the url info into argument code which I can place in the argument section of the views block.

I shall be grateful, if someone here is able to provide any suggestion or solution.

Thanks

Comments

Froggie-2’s picture

Never mind! Found a round about way to get this done.
I'm using this for displaying keyword search results where the main views page displays the teasers and the side bar block displays relevant content of the search (google adwords type).

For views users who would like to have similar feature of having their views blocks display relevant content on the same views page, you may find this useful.

Here is what I did:

1) Created a single view called: "search_keywords" with a default setting with exposed filters (in my case a exposed search text box and an exposed taxonomy term drop down filter).

2) Added a views page with same exposed filters on the aforesaid views.

3) Added a views block with similar exposed filters on the aforesaid views.

4) Added a views attachment with similar exposed filters on the aforesaid views and in the attachment settings for attachment, enabled the check box to attach the attachment content with the views block. Also, enabled the attachment to inherit the parent argument and the parent filter settings and checked the checkbox to show the contents before the block contents.

5) In the Drupal Admin Blocks section, configured the views block to display only on the views pages.

Done!

Now whenever the views pages are viewed through search queries, it calls for the views block where the contents from the attachments are displayed.

The benefit from this is to have a feature where in the views page itself (a non node page) relevant contents (say for example "Node Title" only from search results) can be displayed in the side bars or anywhere else on the page.

It would have been much better if views block had the ability to read the url of the page generated from exposed filters by itself and display relevant contents by itself but since it does not inherit exposed filter settings from the url and views attachments is capable of inheriting parent views settings (both arguments as well as filter settings) I thought it would be best to combine views blocks and views attachments to get what I need in my case.

If I had arguments in my views page url, I would have then used php code in the views blocks argument settings to display relevant content on the views page in views blocks but as my views page is a keywords search results page arising from exposed filters in the search form, I opted for this round about way.

Hope this helps someone with similar requirements.

merlinofchaos’s picture

Status: Active » Fixed

Marking fixed based upon the "Never mind!" comment.

Status: Fixed » Closed (fixed)

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

socialnicheguru’s picture

Thanks for this. I have been thinking about this for a bit.