1

I am working on a music site with a couple other programmers who have left.

We are using taxonomy terms or "tags" for each node, to determine the url/subdomain the node will be shown, on effectively creating different subdomains of content.

There is only one debug statement in the code, and even if there was another hiding somewhere, it does not explain why it shows two different arrays from the same taxonomy on the homepage.

I use the following code to reveal what terms are associated with the node:

 $terms = array();

 foreach($node->taxonomy as $term) {    
   $terms[$term->name] = $term->name;
 }

 print 'debug:<pre>' . check_plain(print_r($terms , 1)) . '</pre>';

I get the following output:

    debug:
    Array
    (
        [national] => national
        [nyc] => nyc
    )
    debug:
    Array
    (
        [national] => national
        [nyc] => nyc
    )

Why is it showing 2 groups of arrays from the same taxonomy? The posts are only tagged once with these two tags "national" and "nyc."

Also on any nodes tagged with only "national," "washington" shows up as well in the duplicate array. I think it may be coming from another content type because when I performed a redirect on the node, using

unset($terms['national']);
      $value = array_shift($terms) ;
      if($region != $value) {
        $link = 'http://' . $value . '.thedelimagazine.com/' . drupal_get_path_alias("node/$node->nid", $path_language = '');
        drupal_goto($link, $query = NULL, $fragment = NULL, $http_response_code = 301);

it redirected to a different content type "CD of The Month." using term "washington" it should choose the other term in the first array; in the case above "nyc." and go to the same node type in this case "blog," I performed this redirect using drupal_get_path_alias for other logic cases and it worked fine.

<pre>
debug:
Array
(
    [national] => national
)
debug:
Array
(
    [national] => national
    [washington] => washington
)
</pre>

The debug is called inside this function

function region_filter_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  /*global $user, $base_url;*/
  switch ($op) {

    case 'view':

      if( (arg(1) == 0)){ }

      else { 

The site is http://www.thedelimagazine.com.

2

Is this in a hook function? It's possible your hook function is being called more times than you expect which gives you your extra debug statement.

| improve this answer | |
  • yes it is in hook node api. but why the two different arrays? i think it is coming from a different content type "CD of The Month." I added this info into my question – albo Dec 28 '11 at 15:11
  • this is not the right answer but i doubt the question will be answered and i want the points on my account. – albo Dec 31 '11 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.