Active
Project:
Signup
Version:
6.x-1.0-rc3
Component:
Views integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2009 at 12:39 UTC
Updated:
15 May 2009 at 09:26 UTC
Hello,
I want to display the signup status of current nodes in the views template. Refering to the signup_handler_field_signup_node_link.inc file, I tried this :
<?php print $node->$signup_handler_field_signup_status; ?>
but it doesn't work.
What's the solution?
Thanks
Comments
Comment #1
dwwI think you're looking for the "Signup: Status: Open/Closed" views field. Add that to your view, and then theme it however you want.
Comment #2
spasmody commentedSorry my request was not clear. I want to add the signup status in a preprocess script (mytheme_preprocess_views_view_unformatted) in order to theme rows with something like this :
So to achieve this I tried
but it doesn't work.
How can I proceed?
Thanks
Comment #3
dwwA) You realize that's potentially very inefficient, right? You're calling node_load() on every single node returned from your view. If you do that, you might as well make your view as trivial as possible and just have a nid field, instead of doing complicated JOINs to get other fields.
B) If you're doing a full node_load(), the signup status of a node is stored in
$node->signup_status.C) It might not be hurting anything, but I don't think you want this:
$terms = array_keys($node->signup);D) You never clear $classes, you just keep appending to it.
Something like this should be closer to what you need:
However, the more efficient solution would be to include the field as I explained in #1, and then look at
$item->whatever_it_isto see the value of this field, use that to append to the classes, and don't actually display the field itself. Getting that right is left as an exercise for the interested reader. I strongly recommend learning how to use a debugger or setting messages with the output of var_export() to figure out what's going on. devel.module can be very helpful, too.Good luck,
-Derek
Comment #4
spasmody commentedThis script makes exactly what I want, and I actually get the expected result. Unfortunately I don't have the right class, I mean I obtain
in ALL nodes, including nodes with enabled signup.
What's wrong?
Comment #5
dwwAre you talking about "signups enabled" (as in, this was at some point a signup-enabled node) or "signups open" (as in, users can currently sign up for this node)?
Comment #6
spasmody commentedI'm talking about "signups enabled". I also tried to clear class after
$node = node_load($item->nid);but it doesn't work.Comment #7
spasmody commentedComment #8
dwwThat wasn't clear. If you just want to see if signups are enabled on the node at all, you want this:
Comment #9
spasmody commentedIt doesn't work. I added this
and for my 4 events from value 0 1 0 1 respectively, I always obtain 'signup-disabled'
I don't understand why.
Comment #10
dwwI don't either. You must have a typo or something, since it's impossible my code would do that given what you're saying. Please debug this yourself. I've given you plenty of help.
Comment #11
spasmody commentedI totally rebuilded my view and I finally found the origin of problem. When I specify a field by which to group the records, the preprocess script doesn't work but if I leave blank to not group, the script works fine. I think the preprocess script is incompatible with grouping field option in views. It is a bit exasperating. Can I add something at the script to solve the problem?
Comment #12
spasmody commentedComment #13
spasmody commented