Hi

When a view is searched via
Exposed filter (a taxonomy field
and a search field) the result comes
with a URL including ? sign and keywords.
Is there a way (seo friendly) to have
the search result as:

/search keyword/taxonomy keyword

for example.When customer searches,
the url arrives as in a better form for
Seo and bookmarking purposes.
There are sites that forwards customer
search keywords (if keyword falls into
one of navigation categories) to
navigation portions ...

Is the only solution using "redirects"
or some sort of aliasing ?

Thank you

Comments

vdsh’s picture

For the taxonomy filter, you can add a contextual filter on the tags of your content and you'll use url like view/taxonomy_term to filter on your term (you'll have to remove this from "filters criteria" though and create it manually (or there may be a better solution))

I am looking on to do the same for search and order by (to have urls like view/taxonomy_term/optionnal_search_term/order_by_criteria) ... but don't see any easy way to do it.

EDIT : Actually, I have done exactly the same for the search part :
I added a global contextual filter and I used the php validator like this :

$view->search_term = $argument;
return TRUE;

Then, I used a hook_query_alter :

function hook_views_query_alter(&$view, &$query) {

  if ($view->name == 'MYVIEW') {

	// if there is any argument
	$search = isset($view->search_term) ? $view->search_term : false; 
	if ($search != false)
	{
               // Do my search : here filter by username or node title
		$view->query->add_where_expression(0, "node.title LIKE '%".$search."%' OR users_node.name LIKE '%".$search."%'");
		$view->query->set_group_operator('AND');
	}
  }
}

EDIT2 :
Same thing for the "order_by"
I added a global contextual filter and I used the php validator like this :

// I made a security check with the kind of order I allowed (rating / most viewed / last created / ...) so that user cannot manipulates the view

$view->order_by= $argument;
return TRUE;

Then, in hook_query_alter :

function hook_views_query_alter(&$view, &$query) {

  if ($view->name == 'MYVIEW') {

        /* ... */
	$order_by = isset($view->order_by) ? $view->order_by : false; 
	if ($order_by != false)
	{
		$view->query->orderby[0] = array('field' => $order_by, 'direction' => 'DESC');
	}
  }
}
kars-t’s picture

Status: Active » Fixed

Dear fellow Drupal enthusiasts,

this issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project everyone is helping on voluntary basis. So that this is was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex or did not describe the problem comprehensibly.

But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and just a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.

Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.

Help can also be found for it on IRC and in the user groups.

In order to remove this issue, I have set this issue to "fixed"

If there is new information, please re-open the issue.

Status: Fixed » Closed (fixed)

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