CCK dropdown field in a View? and access $node in cck 'allowed values'?
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.5 |
| Component: | Views Integration |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | allowed values, node, php code, views |
Jump to:
Hi,
Hopefully somebody can help me, this is driving me crazy. 2 questions...
1. How do I get a dropdown displayed as a dropdown in a View?
I've got a CCK field that is a dropdown(select list) and it's working fine when editing a node. Can this dropdown be shown in a View as a dropdown?
I've got my view built(using a table style), but the field displays as plain text, displaying the current value of the field, it doesn't display as a dropdown.
I have a node defined as an Ad and I want users to be able to take an action on an Ad from their Ads listed in the View. If you look at the screen design attached I need the user to be able to select one of the dropdown options.
Functionality similar to the Filter would seem to fit the bill, i.e. when selecting a Content filter(in the View), I'd select the CCK field name ' - allowed values' and it gives the dropdown as a dropdown, but this isn't available for the Fields in a View.
2. What field/variable will give me the node id of the node displayed in the View?
The allowed values of the dropdown need to be dynamically built using 'php code' and I'm also struggling to work out how to find the node id of the associated node.
I know the format of the return array but using $node gives me nothing.
<?php
// $node->nid gives nothing
// global $node - this doesn't help either
// using arg() won't work in a view because the view url doesn't include the node id
return
array(
'Accept Offer' => array( 'user1' => "username1",'user2' => "username2"),
'Change Status' => array( 'stat1' => "Closed STC",'stat2' => "Withdraw")
);
?>In the view I can choose the node id field and choose to not display it, but how would I then access this hidden field in the php code that is dynamically building up the dropdown?
For both of these questions I'm sure I could put my code in a view tpl.php file(not sure which one yet), but that's the wrong place to add business logic to solve my problem.
Thanks in advance to any helpful soul that can point me in the right direction!!
| Attachment | Size |
|---|---|
| V5-Screens-MyAds.gif | 24.24 KB |

#1
I guess nobody out there knows?
Maybe I should be looking at creating my own Views handler/plugin?
#2
1) Editable Fields module?
2) Views Custom Field module?
#3
thx markus. I never got a mail about your post, I'll check my settings shortly.
I've done this now. In my template.php I've created a function views_view_field__myview__field() and manually(using drupal api code) read the tables I need and create the dropdown.
Took me while and some investigation, but when I found out how to use pre_process functions in template.php I was away.
Custom field looks like something I could use in the future tho, thanks I'd not seen that module before.