Page 1 of 1

can't understand a function

Posted: Mon Oct 25, 2010 8:38 am
by everydayrun

Code: Select all


function garland_separate_terms($node_taxonomy) {
if ($node_taxonomy) {
//separating terms by vocabularies
foreach ($node_taxonomy AS $term) {
     $links[$term->vid]['taxonomy_term_'. $term->tid] = array(
           'title' => $term->name,
           'href' => taxonomy_term_path($term),
           'attributes' => array(
                         'rel' => 'tag',
                         'title' => strip_tags($term->description)
                         ),
         );
}
//theming terms out
foreach ($links AS $key => $vid) {
   $terms[$key] = theme_links($vid);
}
}
return $terms;
}

the above is a self defined function, i couldn't understand it, first, i don't know why the author didn't do this $node_taxonomy = array();

Re: can't understand a function

Posted: Mon Oct 25, 2010 12:39 pm
by InsanityNet
Can you provide as to what context it is used? There is not much info in the function itself

Re: can't understand a function

Posted: Mon Oct 25, 2010 1:18 pm
by twinedev
I found the function here earlier:

http://timonweb.com/how-to-separate-dru ... vocabulary

I was wondering if you meant "why the author didn't do this $links = array();" since the $node_taxonomy is being populated by the call to the function.

-Greg