K
K
K. A.2016-12-19 12:48:13
Drupal
K. A., 2016-12-19 12:48:13

How to set the format for url-addresses during the transition?

It was necessary to implement a block with links to search results pages on the page with the search filter. I did it, the question arose about the CNC: it is necessary that all links leading to the issuance of the filter have the form of the CNC, i.e. instead of

drupal-test/catalog/kabel?section_cable%5B%5D=2

the address bar displayed the address, in this case, this:
drupal-test/catalog/kabel/section/2

Some smart guy hid the filter module itself somewhere inside the kernel, so after looking for it for a while, I decided to quit this business. Instead, I taught Drupal to understand the required link format by using a hook hook_url_inbound_alterlike this:
function semantic_search_url_inbound_alter(&$path, $original_path, $path_language) {
  $parts = explode('/', $original_path);
  if($parts[1] == 'kabel' && !empty($parts[2]))
  {
    if($parts[2] == 'razdel')
    {
      $_GET['razdel_cable[]'] = $parts[3];
      $path = 'catalog/kabel';
    }
    elseif($parts[2] == 'type')
    {
      $_GET['type_of_cables[]'] = $parts[3];
      $path = 'catalog/kabel';
    }
  }
}

The fact is that by clicking on the link of the desired type, Drupal redirects to the filter page with a "non-NC" address.
Is there some kind of hook, or maybe another way to change the display of links in the filter? Or somehow you can create the alias you need programmatically (if it doesn’t exist yet)
I don’t want to use RewriteRule, because the site is crooked and there are quite a lot of links in the filter, and filters on some pages are used different for some kind of horseradish.
Drupal version - 7.22

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question