You are here

facetapi_pretty_paths_coder_taxonomy.inc in Facet API Pretty Paths 7

Same filename and directory in other branches
  1. 6.3 plugins/coders/facetapi_pretty_paths_coder_taxonomy.inc

A taxonomy specific coder for pretty paths.

File

plugins/coders/facetapi_pretty_paths_coder_taxonomy.inc
View source
<?php

/**
 * @file
 * A taxonomy specific coder for pretty paths.
 */

/**
 * Taxonomy specific implementation of FacetApiPrettyPathsCoder.
 */
class FacetApiPrettyPathsCoderTaxonomy extends FacetApiPrettyPathsCoderDefault {

  /**
   * Taxonomy special case: <alias>/<term-name>-<term-id>
   *
   * @see FacetApiPrettyPathsCoderDefault::encodePathSegment()
   */
  public function encodePathSegment(array $args) {
    if ($term = taxonomy_term_load($args['segment']['value'])) {
      $args['segment']['value'] = $this
        ->prettyPath($term->name) . '-' . $term->tid;
    }
    return parent::encodePathSegment($args);
  }

  /**
   * Taxonomy special case: <alias>/<term-name>-<term-id>
   *
   * @see FacetApiPrettyPathsCoderDefault::decodePathSegmentValue()
   */
  public function decodePathSegmentValue(array $args) {
    $exploded = explode('-', $args['value']);
    $args['value'] = array_pop($exploded);
    return parent::decodePathSegmentValue($args);
  }

}

Classes

Namesort descending Description
FacetApiPrettyPathsCoderTaxonomy Taxonomy specific implementation of FacetApiPrettyPathsCoder.