You are here

function ed_classified_link_alter in Classified Ads 6.2

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

Implements 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 332
Simple text-based classified ads module.

Code

function ed_classified_link_alter(&$links, $node) {
  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)) {

    // Only if there are links...
    $tax = $node->taxonomy;
    if (!empty($tax)) {
      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,
            )),
          );
        }
      }
    }
  }
}