[consulting] Help anyone?

Christopher M. Jones cjones at partialflow.com
Fri Sep 10 14:29:11 UTC 2010


Wait. My bad. That line -hides- the block when all the desired terms 
were found. I think the TRUE and FALSE returns should be switched in the 
code sample in the comment. As it is, the block is hidden when all the 
terms in the array are found. Otherwise, it is visible-- whether its a 
node we're on or not.

On 09/10/2010 09:55 AM, Christopher M. Jones wrote:
> Will you elaborate what you're trying to do? I briefly skimmed the
> thread, and the linked one, as well. Seems like a lot of use cases
> jumbled into one. What is yours? You want a block to show up depending
> on what terms were selected for the node? Correct me if I'm wrong, but
> don't all terms show up in the taxonomy property of the node object,
> regardless of whether they are children of other terms? So you should be
> able simply to put the tids of all the terms into that array in the
> first line.
>
> Also, note that this line seems to be checking that -all- the terms in
> the array were found:
>
> <code>
>     if ( $found == count($desired_terms) ) {
>       return FALSE;
>     }
> </code>
>
> So, if you were expecting to show this block on a node that has one or
> more of the $desired_terms then you would need to do something like this:
>
> <code>
> $desired_terms = array(11, 1, 6, 7, 5, 4, 2);
>     $found = 0;
>
>     if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
>       // Yes, we're viewing a node in view mode.
>
>       $node = node_load(arg(1)); // cached
>       // If the term does not exist we're done
>       if (is_array($node->taxonomy)) {
>         foreach ($node->taxonomy as $term) {
>           if ( in_array($term->tid, $desired_terms) ) {
>             return TRUE;
>           } //if
>         } //foreach term
>       } //if
>     } //if node
>     return TRUE;
> </code>
>
>
> On 09/10/2010 04:23 AM, liza chua wrote:
>> Hi! Guys.. can anyone help me with this one? I'm no good in PHP.
>>
>> http://drupal.org/node/134428#comment-3414224
>>
>> Any help would be appreciated.
>>
>> Thanks!
>>
>>
>>
>> _______________________________________________
>> consulting mailing list
>> consulting at drupal.org
>> http://lists.drupal.org/mailman/listinfo/consulting
> _______________________________________________
> consulting mailing list
> consulting at drupal.org
> http://lists.drupal.org/mailman/listinfo/consulting
>


More information about the consulting mailing list