I am having an issue with all my blank cck fields - they are put out just like those fields which are supplied with content. The weird thing is, that the problem must've originated within the last 1/2 months. Before that, empty fields were not displayed on the frontend. So I start figuring, it must've started after the last Update of Drupal (6.10).
I am using content-type.tpl.php code to control the output (no contemplate). Here is an example of a "date" type content template which worked just fine some months ago (please excuse the length of it).
<?php
// Format the teaser image
if ($field_image_standard_thumb) {
$image_standard_thumb = theme('imagecache', 'desaturate_-_resize_182px-110px', $field_image_standard_thumb[0]['filepath'], $node->title, $node->title);
}
?>
<div class="node">
<?php // Teaser view
if ($teaser): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<div class="meta">
<span class="submitted"><?php print $submitted ?></span>
<?php if ($terms): ?>
<span class="terms"> in <?php print $terms ?></span>
<?php endif; ?>
</div>
<div class="content">
<?php if ($image_standard_thumb): ?>
<div class="field field-type-image field-field-image-standard-thumb imagefield-nodelink">
<div class="field-items">
<div class="field-item odd">
<!--
<?php // Print the teaser image as a link to the full node.
print l($image_standard_thumb, 'node/'. $nid, array('html' => 'TRUE')) ?>
-->
<?php // Print the teaser image and link it to the fullsized image.
print l($image_standard_thumb, imagecache_create_url('scale_500px_max', $field_image_standard_full[0]['filepath']), array('html' => 'TRUE', 'attributes' => array('class' => 'imagefield-field-image-standard-thumb', 'rel' => 'lightbox[]', 'title' => $node->field_image_standard_full[0]['data']['title']) ) ); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php print $node->teaser ?>
<!-- Other content here -->
</div>
<?php // Full view
else: ?>
<div class="meta">
<span class="submitted"><?php print $submitted ?></span>
<?php if ($terms): ?>
<span class="terms"> in <?php print $terms ?></span>
<?php endif; ?>
</div>
<div class="content">
<?php if ($image_standard_thumb): ?>
<!-- Div wrap with class for the nodelink.
<div class="field field-type-image field-field-image-standard-thumb imagefield-nodelink">
-->
<div class="field field-type-image field-field-image-standard-thumb imagefield-gallerylink">
<div class="field-items">
<div class="field-item odd">
<!-- Print the teaser image as a link to the full node.
<?php
print l($image_standard_thumb, 'node/'. $nid, array('html' => 'TRUE')) ?>
-->
<?php // Print the teaser image and link it to the fullsized image.
print l($image_standard_thumb, imagecache_create_url('scale_500px_max', $field_image_standard_full[0]['filepath']), array('html' => 'TRUE', 'attributes' => array('class' => 'imagefield-field-image-standard-thumb', 'rel' => 'lightbox[]', 'title' => $node->field_image_standard_full[0]['data']['title']) ) ); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php print $node->content['body']['#value'] ?>
<?php if ($field_text_review): ?>
<?php print $node->content['field_text_review']['#children'] ?>
<?php endif; ?>
<?php if ($field_file_audio_preview): ?>
<?php print swf($node->field_file_audio_preview[0]['filepath']); ?>
<?php endif; ?>
<!-- Other content here -->
</div>
<?php endif ?>
</div>
I have already tried creating a field.tpl.php and adding
// hide empty fields from display
if (!$items[0]['view']) return;
... as written by Moshe Weizmann here: http://www.tejasa.com/node/127
This one did not work. So i guess, I have to add some *else* arguments to my tpl.php's? Some advice would be really appreciated!
Comments
Comment #1
mimhakkuh commentedBy now I am quite sure it is not a problem of the drupal version upgrade but it might have something to do with either cck 6.x-2.2 or the latest versions of imagefield and filefield (because the fields showing up in a blank state are imagefields as well as filefields (audio combined with swftools' flash player).
Did anyone experience the same problem after the last upgrade of CCK?
Comment #2
travismiller commentedi have just experienced this same issue.
this happened when i moved the site from one host to another. the new host renders all imagefield fields, no matter if they are empty or not. this was and still is not the case on the old host. each empty field is rendered with
<!-- File not found: -->which appears to come from imagefield.module:248Drupal 6.10
CCK 6.x-2.2
FileField 6.x-3.0-beta3
ImageField 6.x-3.0-beta3
PHP 5.2.6
MySQL 4.1.11 (old host)
MySQL 5.0.67 (new host)
Comment #3
mimhakkuh commentedinteresting - does this also affect other cck field types of yours. or is it just the imagefields?
i find it irritating that for example my empty textfields work just fine without content, even though i am using basically the same php:
text (only printed, if there's content):
vs.
file (via swftools, printed even if blank):
Comment #4
travismiller commentedi only seem to have trouble with the imagefield rendering when empty.
i have determined my problem to have something to do with the filefield module.
after doing a fresh copy of the webroot and database, everything on the new host works fine. but...
on the old host, i have filefield-6.x-3.0-beta3 on the filesystem but the module admin page still thinks i have 6.x-3.0-alpha6.
after copying the webroot and mysql database to the new host, the module admin page on the new host shows that filefield-6.x-3.0-beta3 is the version on the filesystem.
running the database update script on the new host indicates that filefield needs to be upgraded (6100). running the update causes the problems i was having.
clearly i have a problem with the way the filefield module is installed on my old host, but i hate to mess with the working site ;-)
something with the database update in filefield-6.x-3.0-beta3 seems to be the problem point.
Comment #5
karens commentedThis looks like an imagefield issue.
But if you see the wrong version when you look at the modules list, that is a clue that you have an old version somewhere in your system that is being used instead of the newer version you *think* you're using. Empty your file folder completely before uploading the new version and also look in other folders to be sure you don't have an old version somewhere else.
Comment #6
mimhakkuh commentedConsidering both imagfield and my mp3-filefield share a dependency on filefield module i was thinking that it must be an issue with filefield. I checked if theres an old version somewhere in my modules folder, but that is not the problem. The module page shows that my in-use-filefield version is the latest one. I guess the tpl.php syntax i use must be correct (it worked at an earlier point of time), so now, i am still pretty clueless on what is causing the actual malfunction.
Comment #7
travismiller commentedSo I seem to have two separate issues.
1)
No matter what I do, my old host setup is still showing filefield-6.x-3.0-alpha6 in admin/build/modules. On the new host, admin/build/modules will correctly reflect the filefield version that is on the filesystem. ???
I have removed cck, filefield and imagefield modules from both the new and old host filesystems and replaced them with new downloads from durpal.org.
I have dumped mysql from the old host and imported into the new host.
I have dumped mysql from the new host and imported into the old host.
I have dumped mysql from the old host, imported into the new host and updated filefield from alpha6 to beta3, then dumped from the new host and imported into the old host.
Still after everything, the old host admin/build/modules always shows filefield-6.x-3.0-alpha6 and the new host always shows what is on the filesystem!
2)
As expected, empty CCK fields never render, unless, on the new host I run update.php and run update filefield 6100. In which case only empty imagefield fields render out. The old host never gives me the option in update.php because it still thinks its filefield-6.x-3.0-alpha6.
Host info...
Old Host: mediatemple grid server
New Host: ubuntuserver-6.10 with stock apache2,php5,mysql-server
Comment #8
mimhakkuh commentedI have solved my issue now by downgrading filefield back to version "6.x-3.0-alpha7". No more probelems with blank fields. I guess I will post this to the filefield issues.
Comment #9
quicksketchmimhakkuh, I believe this problem with the empty fields being printed has been fixed. See #417274: Empty fieldgroup gets displayed, if filefield is set to "List field: enabled" for my explanation there. I've checked the variables within node.tpl.php and FileField (and ImageField) now behave exactly like all the other fields provided by CCK. The RC1 version of ImageField and FileField were just released containing these fixes.
I'd like to discourage you from downgrading unless you also restore a database backup. From alpha7 to beta3 there are several database updates that will only be run once. If you upgrade, downgrade, then upgrade again later, your database will not be in the format that FileField expects and you might run into strange (unreproducible) problems in the future.
Comment #10
mimhakkuh commentedThx for the detailed info, quicksketch - too bad, I have already up- and downgraded. I guess that means that my db will be warped after the rc update ... considering this scenario, and the fact that i did not make a db backup I guess I will have decide between manually trying to fix the db or to uninstall filefield and to re-create all custom content types depending on it. I wonder which solution is the less worse?
Comment #11
mimhakkuh commentedAnother update - I now have tried the rc1 version of filefield and the problem of empty filefield related cck fields remains an issue. So maybe the problem after all is not the issue which quicksketch was referring to?
Comment #12
quicksketchmimhakkuh, I'm afraid you might be out of luck on this. Without a way to reproduce this problem there's nothing more I can do help. You might considering hiring help from http://drupal.org/drupal-services to correct the problem on your site.
Comment #13
mimhakkuh commentedyour're right, i think this is difficult to reproduce, maybe somone might have an idea anyway. this is what i did.
1. i deleted all filefild related cck fields
2. deactivated filefield and dependent modules
3. uninstalled filefield and filefield meta
4. cleared the cache
5. installed filefield (rc1) again
6. re-created the cck fields i had deleted (same title convention)
7. uploaded data into the re-created fields (image, audio files)
i tried again - and the result is:
1. nodes without any image content do not show empty image fields anymore, those with image content show images correctly.
but
2. if i save nodes without any image content (without inserting images) again, the empty fields start showing again.
... the recreated fields used for flv-audio behave in another way. they start showing empty fields right away.