3

I am using Search API. I make a view of all the indexed entities and uses Taxonomy term as Contextual Filter. But the path of view is not SEO friendly. The path is like http://www.example.com/en/Real%20Estate.

I want to make this path SEO friendly and convert this space(%20) to dash. In views I am getting configuration "Convert dashes into spaces" for contextual filter.

I tried to alter the views and implement hook_views_pre_render, hook_views_post_render, hook_views_post_build and hook_views_post_execute. This time it is not showing the results.

Can anyone help me regarding this?

  • Did you find a solution for that? – rreiss Nov 3 '16 at 15:18
0

I managed to do that with the following code:

/**
  * Implements hook_views_pre_view().
  */
 function hook_views_pre_view(&$view, &$display_id, &$args) {
   /* Search page view */
   if ($display_id == 'search_page' && !empty($args[0])) {
     $args[0] = strtr($args[0], '-', ' ');
   }
}

You should also adjust the search form ofcourse..

-1

Facet Pretty Paths module to the rescue https://www.drupal.org/project/facetapi_pretty_paths

  • I think Facet Pretty Paths module is only used to make changes in the parameters of facets in URL. – Pankaj Sachdeva Jun 9 '16 at 9:33

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.