You are here

function ed_classified_link_alter in Classified Ads 5

Same name and namespace in other branches
  1. 5.2 ed_classified.module \ed_classified_link_alter()
  2. 6.2 ed_classified.module \ed_classified_link_alter()
  3. 7.2 ed_classified.module \ed_classified_link_alter()

Implementation of hook_link_alter (&$links, $node) Find and destroy old taxonomy links for the classified ads node. This will create links to the custom classified ads taxonomy view. This would be easier if the hook callback knew what module was calling it, and the type of links that were just added. Since we don't we have to do some checking to find what we are looking for.

File

./ed_classified.module, line 287
Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…

Code

function ed_classified_link_alter(&$node, &$links) {
  module_load_include('inc', 'ed_classified', 'ed_classified_utils');

  // array with keys like [taxonomy_term_n] => title, href, etc.
  if (_ed_classified_node_is_classified($node)) {
    $tax = $node->taxonomy;
    foreach ($tax as $t) {

      // kill any links like taxonomy_term_n
      // OR, replace them with links to ed_classified/tid/n?
      $key = 'taxonomy_term_' . $t->tid;
      if (_ed_tid_is_classified_term($t->tid) && isset($links[$key])) {
        $links[$key]['href'] = _ed_classified_make_category_path($t->tid);
        $links[$key]['attributes'] = array(
          'title' => t('View other ads like this one in the \'!cat\' category.', array(
            '!cat' => $t->name,
          )),
        );
      }
    }
  }
}