Project:Custom Formatters
Version:6.x-1.4-beta1
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

What if you add a checkbox on the basic editor form which says something like, "If this field is empty, return a blank string"?

For instance, I have a CCK field which allows users to upload an MP3. I'm using the Custom Formatters module to create a formatter which embeds that MP3 into a SWF file. If the CCK field is left blank, I don't want any output generated. So, I think giving the user an option to hide empty fields, or return blank output, would be very useful.

Comments

#1

Hi joelstein,

I'm thinking that it may not even be necessary to give the option but instead just not return any data if the field is empty.
I really can't see any situation where providing output for an empty field would have any benefit.

This will likely be done in the next development release which should be out in the next 12 hours or so.

Cheers,
Deciphered.

#2

Status:active» fixed

Done and committed to DRUPAL-6--1.

#3

Thanks!

#4

Version:6.x-1.2» 6.x-1.4-beta1
Status:fixed» needs work

Since the 1.3 version (I think), this behavior is not working. My (basic) custom formatter appears once again, even if the field is empty. For what it's worth, I'm using a filefield type.

#5

Category:feature request» bug report

Confirmed, it was re-introduced in 1.4-beta1. Unfortunately the way I made this feature work is not the best way to do it, but the only way I can really see, but it causes quite a few PHP notices (only visible in debug mode).

To fix it for the moment, and likely the fix that will make it in to the next stable version (until I can come up with a better option), do the following:

Change modules/token.inc line #47 from:

      if (!empty($object[0])) {
        if (module_exists('filefield')) {
          $file = $object[0];
          $values['filefield-alt'] = $file['data']['alt'] ? $file['data']['alt'] : '';
          $values['filefield-title'] = $file['data']['title'] ? $file['data']['title'] : '';
          if (module_exists('imagecache')) {
            foreach (imagecache_presets() as $preset) {
              $values['filefield-imagecache-' . $preset['presetname']] = file_directory_path() . '/imagecache/' . $preset['presetname'] . str_replace(file_directory_path(), '', $file['filepath']);
            }
          }
        }
      }

To:

      if (module_exists('filefield')) {
        $file = $object[0];
        $values['filefield-alt'] = $file['data']['alt'] ? $file['data']['alt'] : '';
        $values['filefield-title'] = $file['data']['title'] ? $file['data']['title'] : '';
        if (module_exists('imagecache')) {
          foreach (imagecache_presets() as $preset) {
            $values['filefield-imagecache-' . $preset['presetname']] = file_directory_path() . '/imagecache/' . $preset['presetname'] . str_replace(file_directory_path(), '', $file['filepath']);
          }
        }
      }

Sorry about that, looks like I need to write some tests at some time.

Cheers,
Deciphered.

#6

Yes, that patch does the trick. Thanks!

#7

Status:needs work» fixed

I rewrote this functionality as the existing way was causing too many side issues. Dev release should be available in a few hours, would be grateful if you could test it out.

Cheers,
Deciphered.

#8

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here