I have a problem with a CCK field that I want to make searchable. I have put this field on the Finder but the dropdown list displays the IDs instead of the names. The CCK fields - if only specified field values are allowed - have the option to specify a field value ID and name like this:
1 | Field value
But the Finder module displays the ID only. Is it possible to change this behaviour? I think in all cases it makes sense to display the name and the ID as a select option form element value, only of course if the IDs is used by the CCK field.
Otherwise, this is a great module that helps me a lot with implementing the functionality I need for my site. Thanks!
Bence
Comments
Comment #1
danielb commentedIt's possible to theme the options and use cck's functions to get the proper display title. I don't know if there is any way to do this by default with Finder Views unless someone else has a suggestion.
Comment #2
danielb commentedYou could start by implementing this theme function and debugging the two incoming variables, firstly you need to identify the correct $element before making any decision (usually by the 'finder_element_id'), and then look at what information is available about the result in the $option object, and then go from there.
http://www.braksator.com/api/function/theme_finder_optionwidgets_select_...
Comment #3
bbence commentedThanks, I will check this.
Comment #4
danielb commentedComment #5
ShutterFreak commentedWhat should I do to do what's posted in reply #2?
Comment #6
danielb commentedIt's a theme function - http://drupal.org/node/477136
you have to put it in template.php and rename the theme_ part of the function name to your theme name
Comment #8
bbence commentedSorry, I think I need to reopen this. I have checked the theme hook possibilities for getting this to work but unfortunately in the variables for the theme_finder_optionwidgets_select_option the information is not available for the "non-key" values of a CCK field. So I cannot easily output the "text" instead of the "id".
I think it is a quite common scenario that some CCK fields have such an approach (key|value list of values).
Any chance to support this, or at least send some more info about the field to the theme functions, so that such finder lists can be outputted correctly?
Thanks!
Bence
Comment #9
danielb commentedI can look into it but I wouldn't get my hopes up.
Yes the actual display value isn't available in the theme function, if it was this wouldn't be an issue, but the key value is there, and somehow the key value correlates to the display value you set, so you should be able to make that conversion somehow - perhaps CCK has some functions available to automate it.
Comment #10
bbence commentedThanks for looking into it daniel. Actully I have gone a bit "deeper" in the finder module and outputted several arrays in order to be able to find out what should be passed to the theme hook functions for the optionwidgets, but couldn't find anything useful. Yes, probably some functions for CCK exists but this info has to be read by finder in the part where it's building the possible selection options. I wonder how CCK / views does it, I mean displaying the value instead of the key.
Also it gets even more complicated with computed fields where the whole PHP code to get the value (display value) is stored in a database field...
Comment #11
danielb commentedThe reason views does it is because of that little options screen that comes up in views after you pick a field. Actually if I found a way to get that options screen into finder it would solve a lot of problems, I'm just worried some of the options are very views specific and that will be an issue.
The other thing is also that you won't able to do something like autocomplete or search on the value of the field, only the key, so this feature would be misleading.
I really think the theme function is your best bet unless someone can suggest a clever patch.
where 'field_cck' is the cck field and 'page' is the content type for which to check the settings - if you need to get these values dynamically it may be possible, but tricky, to derive it from data in the $option and $element objects but it may require a database lookup based on the nid.
Comment #12
danielb commentedIf anyone has any ideas or more information that could enable us to use the cck value rather than the key in Views queries please post here - otherwise I don't think this is fixable unless we create our own 'cck finder' which I may have to do - but then it will be mutually exclusive to Views.
Comment #13
danielb commentedIf anyone has any ideas or more information that could enable us to use the cck value rather than the key in Views queries please post here - otherwise I don't think this is fixable unless we create our own 'cck finder' which I may have to do - but then it will be mutually exclusive to Views.
Comment #14
danielb commentedIf anyone has any ideas or more information that could enable us to use the cck value rather than the key in Views queries please post here - otherwise I don't think this is fixable unless we create our own 'cck finder' which I may have to do - but then it will be mutually exclusive to Views.
Comment #15
danielb commenteduh
Comment #16
Javier commentedSame problem here, hope someone can help!
Comment #17
hey_germanoI was able to get a select list that was outputting IDs instead of names to output the names by adding this to the "Rewrite options" field:
I'm stuck on one thing, though - the names aren't in any recognizable order. Is there something I can add to my Rewrite code that'll sort these options alphabetically?
Comment #18
hey_germanoJust needed to rearrange my sort order options on the view itself, not in the rewrite code.
Comment #19
rwd commentedFor a CCK field named "field_foo_bar" with both keys and values, to show the values in the Finder form instead of the keys, put this PHP code into the Finder element's rewrite options:
Comment #20
nedim.hadzimahmutovic commentedI solved this using following rewrite code:
Comment #21
kolossus commentedHEY_GERMANO ... You're a lifesaver. Bless ye
Comment #22
mlyno commentedThis helped for my case. I used CKK on OG. Multi selection of taxonomy driven view did returned only IDs. It works now.
Thanks Nedim Hadzimahmutovic.