2

I know there are some easy tricks to hide Views fields conditionally (catchword: hide if empty). None of them seems to work for me. Also hook_views_pre_render() or other preprocess approaches didn't work since they never touch the row in a way where I could have unset that certain field I'ld like to hide conditionally.

This is the setup I have to work with:

[field 1] hidden from display
[field 2] hidden from display
[field 3] hidden from display and rewritten to output <markup>[field 1][field 2]</markup>
[field 4] hidden from display
[field 5] rewritten to output <markup>[field 3][field 4]</markup>

I'ld like to unset [field 3] if comments of that row's nid are closed (if ($node->comment != 2)). I think maybe field handlers are the way to go, but I don't see how. I have to bind some .inc into my custom module, is that right? But which of these many .inc files is the one I have to work with and how would I alter it? Or are there other ways to achive what I need?


I think my main question is somewhere in the direction of "How to conditionally hide rewritten fields?" It seems really dificult to fetch these fields along the processing and unset them. Rebuildung the whole view would maybe bring me even more problems, while lots of css goes with the nested markup. I think it would've been much better to have started without fields and with a view mode instead in the very beginning.

  • Can you expand on your logic a bit? You say you want to hide field 3 but then say it is to be rewritten to include field 2 and itself and then what's going on with field 5 and field 3 again? – Jimajamma Mar 19 '14 at 13:23
  • @Jimajamma - Edited the question. There was a little mistake with the fields. – leymannx Mar 19 '14 at 16:06
  • 1
    Indeed, it might be a bit easier if instead of Fields in your View, you displayed Content (eg the whole node) and then overrode the node display with a node--view--VIEWNAME.tpl.php template and all of this logic in there. – Jimajamma Mar 19 '14 at 23:17
0

in admin panel of that view.. add Filter criteria and select "Content: Comment status"

and then click on apply and then choose closed option in options box

let me know if need any clarification...

Thanks Ashish Raj

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.