Views is a great module but it seems that it is "too" helpful for me in a couple of cases. I am trying to create views that display the Key Value of CCK fields. I would also like to create CSV Downloads that download the Key value and not the label. I have searched documentation and the forums on and off for several weeks trying to find something on this and have not had any luck.
Basically, I have several CCK fields that use a Key|Label format for Allowed Values. The Labels are great with our general web users but from an administrative view point I need to just see the Key Value. For one thing a Key Value of 'A' takes up a lot less room in a view than a 20+ character label. The label for Key "A" will change each year but from my view point. I just need to see A.
I have played with settings in CCK and found nothing that changes the behavior of views in this regard. In a node I found that ..fieldname['value'] displays the Key while ..fieldname['view'] displays the label but I have not found anyway to tweak Views.
So.. Is there some way to have the Key Value displayed in lieu of the Label Value in Views?
Thanks
Charles
Comments
Seems no, by default BUT
Seems no by default BUT probably you can add Global text which can be as short as you wish.
Hi, Did you work out how to
Hi,
Did you work out how to do this? I have exact same problem, the labels are really long but I have nice simple keys for admin use.
Thanks,
Paul.
This seems like a feature
This seems like a feature that should be readily available. I'm wanting to rewrite a field to link in an image from the filesystem using the key value of a select list. Something link
For those of you looking for
For those of you looking for a workaround, use the Views CustomField module and pluck the value out of the $data array: http://drupal.org/project/views_customfield
customfield module works
i've faced this a year ago, and i remember doing something similar to 'canesWin'. This should work.
I'm also trying to figure
I'm also trying to figure this out, how would this be done with customfield?
Use the Customer Formatters module
You can do this with the Custom Formatters module. http://drupal.org/project/custom_formatters
1. After you install the module, go to Site Configuration > Customer Formatters and create a new custom formatter. I called my 'Raw select key'.
2. Configure as follows:
Field type: text
HTML: [raw]
Click Save.
3. Edit the View and under the Fields section, click the relevant CCK field and change the Format to 'Custom: Raw Select Key'.
That should do it. A very elegant solution.
Thank you!
I confirm this solution works very well. Thank you so much.
thanks graymalkin
that was very helpful
Hmmm. Just displayed the cck
Hmmm. Just displayed the cck field token on view. Didn't convert. Basic editor. No WYSIWYG or input format options.
http://ItsAboutTyme.com
Drupal 7 ?
I tried doing this on Drupal 7 but I didn't see anything RAW in the tokens ...
And the field type shouldn't be list (text) ?
Small issue
Worked for me... but turned out to be really slow when going through 100 rows. Render time went from 700 ms to 3000ms. If you only want to go through a few iterations, it should be fine though.
Drupal 7
I second that, what is an easy and good way to achieve that in Drupal 7 / Views 3
My Drupal 7 way
In case someone might still be wondering how to do this in Drupal 7, here is how I did it using default views3 capabilities:
*) In the 'Rewrite results' section of your field,
-) check the box 'Rewrite the output...'
-) and set as value [<your_field_name>-value] (you can find allowed replacement values in the list below the input field)
*) In the 'Style settings' section of your field,
-) check the box 'Customize field HTML'
-) and select 'None' for HTML element
And then field->content will return the key of the selected value.
My Drupal 7 way not working :(
This isn't working for me. I've added the field. Below added another one, then done the steps that you have stated. But within the rewrite results section. The field does not appear in the replacement values. Do you know a solution? Thanks.
Drupal 7 Views 3.0 appears to
Drupal 7 Views 3.0 appears to have this available on screen labeled formatter just under the exclude from display setting.