Active
Project:
Content Construction Kit (CCK)
Version:
6.x-2.9
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Jan 2008 at 17:01 UTC
Updated:
21 Jul 2011 at 19:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
xjmThis is a feature I need as well. I will try applying the patch and see if it works for me.
Comment #2
xjmWhen I apply this patch, the label item is indeed added to the
$nodeobject. However, something strange happens: node types that use the default CCK-generated body have serious rendering errors as soon as I apply the patch. I furthermore cannot get rid of the rendering errors simply by reverting the patch; I have to resubmit each and every node that uses the CCK-generated body so that the body goes back to the way it's supposed to be. (So: as usual, do not test this patch on production sites.)Here's an example of HTML for a field with the un-patched CCK body.
When the patch is applied it immediately becomes:
It looks like CCK is treating the label as an additional field item, as if it were part of a list of multiple values. I am betting the text widget recursively uses something like
$field_items[$item_key][0]to get the text strings for multiple values, so that's why it's printing the first letter of the label as an additional field value.So, it looks like your solution is incompatible with the existing CCK text widget display (and possibly other field types that have multiple values). I will do some testing and see if I can come up with a better way to implement your change that will work with these widgets.
Comment #3
xjmI was able to resolve the bug by modifying your code slightly:
This puts the label in the correct array.
I'll roll a revised patch and post it.
Comment #4
xjmHere's the patch. I made it against the 1.7 release version, but it should work just as well for 1.6 and the current dev build. Please review/test.
Comment #5
xjmNB: Same issue is at
http://drupal.org/node/181259
http://drupal.org/node/167539
Comment #6
magnumz commentedTested xjm's patch and now it outputs field label when i use
print $field_name[0]['label_text'];in template ,but the output is not localized. When i use
print t($field_name[0]['label_text']);field's label output is localized. I guess the t() used in patch on field label is not working like it should.Comment #7
xjmI don't know much about how localization works... is there some reason that the localization would not be run until after this bit of code?
Is there anything wrong with the code above?
Comment #8
psynaptic commentedJust like to say I would find this useful. Much better than hardcoding labels into node.tpl.php files.
Comment #9
psynaptic commentedAnd now I see that it's present in the 6.x version!
Comment #10
xjmPatch is still required for this functionality in the 5.x version (most recent is 1.10) which is the version the issue was created for.
Comment #11
psynaptic commentedSorry!
Comment #12
mishoboss commentedI don't get it - psynaptic says it's fixed for 6.x-2.1, but now I updated to 6.x-2.3 and there is still no "label" data...
How could this be done?
Comment #13
xjmThe patch above is specific to the Drupal 5 version of CCK. If the labels are present in the 6.x version of the $node object, well and good. If not, then the patch would need to be ported to the 6.x version or a new patch created.
Comment #14
bur commentedIn 6.x it is possible to print labels in this way:
print $node->content['']['field']['#title']
Comment #15
markus_petrux commentedPlease, see #637636: How to print the field label in node templates.
Comment #17
Anonymous (not verified) commentedYep, I learnd that from http://www.davidnewkerk.com/book/30
<?php print $node->content['field_name']['field']['#title'] ?>to print labels and if your fields are part of a group then use
<?php print $node->content['group_name']['group']['field_name']['field']['#title'] ?>Cheers.
Comment #18
psynaptic commentedThis still kinda sucks though. Ideally, it would be best to have the fully rendered field in the node object including the label and its formatting set in the CCK UI.
Sorry to re-open but I think a new feature request is the right outcome from this point.
Comment #19
sunchaser commentedIs there still no way to call the field label of a cck field in node - view ?
The above suggested
print $node->content['fieldname']['field']['#title']doesn't seem to work on my end.a print_r($node) also reveals the labels are not available in the node object.
Comment #21
FuXXz commentedWhere i can find the solution for this issue?
I want to print the label or the best solution for me is to print the entire CCK Field with label, items, display settings
Comment #22
manute commentedFuXXz you can try with: <? print $node->content['#content_extra_fields']['title']['label']; ?>
In $node->content['#content_extra_fields'] you will find all fields and their labels.
Comment #23
flokosiol commentedThis works fine, but not if the field is inside a CCK fieldgroup. In this case try ...
EDIT: sorry, duplicated entry see #17
Comment #24
Anonymous (not verified) commented#17 worked for me (Thanks, filmoreha!). Echo #18.