You are here

taxonomy_facets.module in Taxonomy Facets 8

Same filename and directory in other branches
  1. 7.3 taxonomy_facets.module
  2. 7.2 taxonomy_facets.module

File

taxonomy_facets.module
View source
<?php

/**
 * Print out menu tree for each vocab selected to be taxo faceted filter.
 *
 *  For each vocabulary id that is passed as an argument output menu tree. Array
 *  of menu tree is passed through the theme function at the end, so themed
 *  output is produced.
 *
 * @param integer $vid
 *   Vocabulary id
 *
 * @return string
 *   Themed menu tree.
 */
function taxonomy_facets_get_menu_tree($vocab_name) {
  $menu = new \Drupal\taxonomy_facets\MenuTree($vocab_name);
  $menu_tree = $menu
    ->getMenuTree();

  // Render the menu
  $menu_items = null;
  foreach ($menu_tree as $item) {
    $menu_items .= render($item);
  }
  return $menu_items;
}
function taxonomy_facets_get_selected_filters($taxo_facets_path = null) {
  $filters =& drupal_static(__FUNCTION__);
  if (!isset($filters)) {
    if ($taxo_facets_path) {
      $taxo_facets_path = explode(':', $taxo_facets_path);
    }
    else {
      $taxo_facets_path = \Drupal::request()
        ->getRequestUri();
      $taxo_facets_path = explode('/', $taxo_facets_path);
      if ($taxo_facets_path[1] === 'listings') {
        array_splice($taxo_facets_path, 0, 2);
      }
      else {
        $taxo_facets_path = null;
        if ($taxo_facets_path = \Drupal::request()
          ->get('taxonomy_facets')) {
          $taxo_facets_path = explode('/', $taxo_facets_path);
        }
      }
    }
    if ($taxo_facets_path) {
      $filters = new \Drupal\taxonomy_facets\SelectedFilters($taxo_facets_path);
    }
    else {
      $filters = null;
    }
  }
  return $filters;
}

/**
 *  Implements hook_theme().
 *
 * Provides 3 theme files for theming filters.
 */
function taxonomy_facets_theme($existing, $type, $theme, $path) {
  return array(
    'taxonomy_facets_menu_leaf_template' => array(
      'variables' => array(
        'menuLeaf' => NULL,
      ),
      'template' => 'taxonomy_facets_menu_leaf-template',
    ),
    'taxonomy_facets_ul_wrapper_end_template' => array(
      'variables' => array(),
      'template' => 'taxonomy_facets_ul_wrapper_end-template',
    ),
    'taxonomy_facets_ul_wrapper_begin_template' => array(
      'variables' => array(
        'menuClass' => NULL,
      ),
      'template' => 'taxonomy_facets_ul_wrapper_begin-template',
    ),
    'taxonomy_facets_remove_filter_template' => array(
      'variables' => array(
        'menuHed' => NULL,
      ),
      'template' => 'taxonomy_facets_remove_filter-template',
    ),
  );
}
function taxonomy_facets_node_presave($node) {
  $nodeTerms = new \Drupal\taxonomy_facets\NodeTerms($node);
}

Functions

Namesort descending Description
taxonomy_facets_get_menu_tree Print out menu tree for each vocab selected to be taxo faceted filter.
taxonomy_facets_get_selected_filters
taxonomy_facets_node_presave
taxonomy_facets_theme Implements hook_theme().