views:

1109

answers:

3

I've got a problem with my site search not linking properly to my views pages. I've got a views page set up to display recipe data. It has the URL properties of:

index.php?q=recipe/%1/%2

where %1 is the recipe category, for example, breakfast, and %2 is the recipe name, for example, Muffin. The view goes through the recipe node content, and display it as appropriate. The problem is that the site search module doesn't link to the view, it links to the node which still can look like:

index.php?q=node/22

If I edit that node with an URL alias I can turn it into say:

index.php?q=recipe/muffin

But: this clashes with the view display on the site and the search function takes them to the NODE and not to the VIEW. I really, really need them to be taken to the view.

Is that clear?

How can it be fixed?

Edit: the view has variables for both recipe category and recipe name (for example, breakfast/muffin). Formatting the node pages themselves was impossible, so we had to use views, I'm afraid.

A: 

What does the view do exactly?

If it searches for nodes with the argument (say, "Muffin") in their titles, then I think that you should simply change the view URL to something like search_recipe and be done with it.

If it does do something like displaying a single node (so recipe/muffin would be an appropriate unique id), then why are you using Views for this?

Also, you can replace the site's search page with exposed view filters. It's pretty powerful.

Eli Krupitsky
Hiya, the view displays select data from the single node. The node is basically a data entry form which was too difficult to theme, so we used views to do it instead. I'll edit my post :)
hfidgen
And... the view also lists summary views of the entire category (eg breakfast). So you can either view a category, or you can view an individual recipe.
hfidgen
Sounds a little complicated - maybe you could try theming the node again instead? What was the problem?As for the summary view - you can use a view block or even something like the Insert View (http://drupal.org/project/insert_view)
Eli Krupitsky
I found a way around it within views using a form in the end. Thanks for your thoughts though!
hfidgen
A: 

This might work?

I've set up a searchable view form - with some filters exposed in the page (and so in the url).

I've disabled site search, don't need it anyway outside this recipe area, and I think I can build a simple block to $GET (or $POST, i always forget) form data to the view.

The view then reads the url and displays appropriately:

index.php?q=recipes%2Fsearch&time=All&keywords=pie

shows recipes containing "pie" in the title.

Just need to build the form now...

edit - yep this worked a treat!

<form id="search-block-form" action="index.php?q=recipes%2Fsearch&amp;time=All" accept-charset="UTF-8" method="get">
<div>
<div class="container-inline right-search">
<div id="edit-search-block-form-1-wrapper" class="form-item">
<label for="edit-search-block-form-1">Quick recipe search: </label>
<input name="q" value="recipes/search" type="hidden" />
<input name="time" value="All" type="hidden" />
<input id="edit-search-block-form-1" class="form-text" title="Enter the recipe terms you wish to search for." maxlength="128" name="keywords" size="15" type="text" />
</div>
<input id="edit-submit" class="form-submit" name="op" type="submit" value="Search" />
</div>
</div>
</form>
hfidgen
A: 

This is kind of a workaround, but:

You can try Google Custom Search Engine as default search, and make Google not see node/* URL's using robots.txt.

Just add this below "# Paths (clean URLs)" in the robots.txt file which is on the Drupal root:

Disallow: /node/

(Don't forget that adding this line will stop search engines from crawling all the node/** URLs.)

Also adding views to the sitemap could be helpful for this process.

I've never tried this process, so I can't be sure if it's working or not ;)

hecatomber
I found a way around it within views using a form in the end. Thanks for your thoughts though!
hfidgen