You are here

function taxo_faceted_navigation_preprocess_node in Taxonomy Facets 7

Preprocess node url and append argument to it.

The problem is that on the teaser listing page (landing page), when user clicks on the node title and goes into the node, the left menu will collapse, as a node url normally does not have information about applied filters. This function is used to fix this problem where the menu tree collapses if you go into the node, by appending this information in the form of url arguments.

Parameters

array $variables: Array of variables to preproccess.

Return value

nothing Does not return anything as $variables are passed by reference.

File

./taxo_faceted_navigation.module, line 975
Taxo Faceted Navigation module code.

Code

function taxo_faceted_navigation_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'teaser') {
    $filters = taxo_faceted_navigation_get_selected_filters();
    if ($filters) {
      foreach ($filters as $filter) {
        $terms[] = $filter['term_path_alias'];
      }
      $categories = implode('/', $terms);
      $url = $variables['node_url'] . '/?categories=' . $categories;
      $variables['node_url'] = $url;
      global $base_url;
      $variables['content']['links']['node']['#links']['node-readmore']['href'] = $base_url . $url;
    }
  }
}