Hi Guys,
Your efforts are great.

I have site where I'm showing facets on taxonomy term page.

http://www.mysite.com/category/country/germany

Now when I select the facet link it make url like this

http://www.mysite.com/taxonomy/term/[tid]/make/chiron

Where I want this to be like

http://www.mysite.com/category/country/germany/make/chiron

Now issue is Drupal is not decoding "category/country/germany" as url alias to show taxonomy page then apply the facet, it take whole url "category/country/germany/make/chiron" which is not a page and shows me page not found.

How can I get this done.

Regards,
Kamran Zafar
http://www.cognitiveaxis.com/

Comments

dasjo’s picture

getting base path right is a tricky thing as it depends on your exact setup, see #1861786: Fix base path issues

vlad.dancer’s picture

Hi, kamranzafar and dasjo.
First of all thanks to dasjo for awesome module.
Yesterday I've bumped into this issue to. And I've found only one method to resolve this task.

First of all we need some kind of patch on method public function getBasePath()
from facetapi_pretty_paths/plugins/facetapi/url_processor_pretty_paths.inc to allow pretty_path get right alias for the base path.

Something like:

if (strstr($basePath, 'taxonomy')) {
  $alias = drupal_get_path_alias($basePath);
  $basePath = $alias;
}

Next if we do this we should get "page not found", when follow updated facetapi link.
It's because there is no such menu route as taxonomy-tem-alias/facet-name/facet-value/facet1-name/facet1-value.

In this case we need tell drupal what is the right system path. I did it using hook_url_inbound_alter().

Something like this can help:

function mymodule_url_inbound_alter(&$path, $original_path, $path_language) {
  if (strstr($path, 'catalog/category')) {
    $exploded = explode('/', $path);
    $alias_str = 'catalog/category/' . $exploded[2];
    $alias = path_load(array('alias' => $alias_str));
    $path = str_replace($alias_str, $alias['source'], $path);
  }
}

I hope this will help you.
BTW: @dasjo is it right place getBasePath method to place special handling for taxonomy type base path getting?
PS: Not sure that this is correct way, but anyway.

dasjo’s picture

hi,

i'm glad you like the module!

1) setting up a search for the path that accepts arbitrary parameters (/%/%) unfortunately doesn't work out of the box as far as i know. at least i didn't have luck with views & panels to do so.

2) we can override taxonomy/term/% with a search api view and then put facets on it to emulate that behavior. did you do so or did you use another method?

3) in this case, as stated in the original report, the term alias isn't used as base path but the internal url:

http://www.mysite.com/category/country/germany

Now when I select the facet link it make url like this

http://www.mysite.com/taxonomy/term/[tid]/make/chiron

Where I want this to be like

http://www.mysite.com/category/country/germany/make/chiron

4) your solution in #2 is a valid approach but requires patching. an alternative solution has been documented in #1468922: URL aliases require workaround but isn't perfect either. if desired, we can add a hook to the FacetapiUrlProcessorPrettyPaths::getBasePath() method.

i would really like to see if there is a solution for 1) but i don't know much about the routing system...

vlad.dancer’s picture

Thanks for sharing another approach.
But I think it is not good when we have tons of links on the page. That method invokes hook on each url() func.
As I know there is no solution for 1) method (at least in Drupal 7).
Also I think getBasePath() is a good place to add taxonomy based base path handling, same as for search_api_facetapi module done. Or create some alter hook in the FacetapiUrlProcessorPrettyPaths::getBasePath() if it's more convenient for you.

vlad.dancer’s picture

Oh, btw, I've used page manager to override taxonomy page.

dasjo’s picture

if concerned about making getBasePath too heavy, we can alter the default base path generated at the end of fetchParams

vlad.dancer’s picture

Sounds good.