سؤال

I have a CCK field in views, in which I have taxonomy terms. Different categories have different sections on the page and there are overlapping categories.

I want to search through the array, find if it has a certain taxonomy value, then print html accordingly I did not figure out anything for the overlapping categories.

<?php
$vu=array('value' => $fields['tid']->content);
if (in_array("Film", $vu)) {
echo "Got Films";
}
?>

This is far as I got, but this is not producing the desired effect. 'tid' is the taxonomy CCK. I am doing this under views fields template, thats why I am not using $node-> etc..

If I just print out $vu I get "Array Array Array Array" etc.

Sorry if I am asking something very simple, but I tried to search on Google, but I failed badly.

EDIT1:

Result of print_r $vu

Product title Array ( [value] =>

  • Taxonomy term 1
  • Taxonomy term 2

)

EDIT2: I think I am figuring out "part" of the problem. The CCK field output is A., html list formatted B., because of that the array is screwed up. Any ideas how to set views to give me "raw" output?

هل كانت مفيدة؟

المحلول

I think you should install the devel module and then use the dpm() function to look through your variables. It takes just a fraction more time to do that now, but it'll save you lots and lots of time in the future, when you're wondering about the crazy structure of some of Drupal's objects and arrays. :-)

Once you've installed the module, just use dpm($fields); and see what you have in there. It's a very user-friendly output.

Let me know if that helps you along!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top