You are here

function taxonomy_facets_preprocess_node in Taxonomy Facets 7.3

Same name and namespace in other branches
  1. 7.2 taxonomy_facets.module \taxonomy_facets_preprocess_node()

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

./taxonomy_facets.module, line 550

Code

function taxonomy_facets_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'teaser') {
    if ($filterNames = \taxonomyFacets\TaxoFacets::getInstance()
      ->getAppliedFilterNames()) {
      $variables['node_url'] = $variables['node_url'] . '/?categories=' . implode('/', $filterNames);
      global $base_url;
      $variables['content']['links']['node']['#links']['node-readmore']['href'] = $base_url . $variables['node_url'];
    }
  }
}