I want to be able to display file attachments in the teaser as well.

The patch for upload.admin.inc creates a setting under upload settings to enable this functionality.
The patch for upload.module uses this setting to show / not show attachments in the teaser.

Further reworks may include the number of files to show in the teaser.

Comments

Gurpartap Singh’s picture

Version: 6.2 » 7.x-dev

Feature additions like that can't make it to Drupal 6 anymore.

maartenvg’s picture

Status: Needs review » Needs work

I really like the idea, but I dislike the proposed implementation. I also have some reservations whether this should go in core, I think a contributed module suits fine.

I would at least make it a setting on the content type forms (@ http://example.com/admin/content/types/content_type). But I would prefer an added checkbox for 'list on teaser' for each file, just as there are checkboxes for 'Delete' and 'List'. That way you can control which files are important enough to be shown on the teaser, and which are not. Of course, with a way to define the default setting on the content type forms.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new46.63 KB
new8.38 KB

I changed the implementation of this feature to the following. It adds:

  1. a new field in {upload}
  2. checkboxes on the upload form for each upload file (see attached screenshot)
  3. an option to set the default for the teaser checkbox, similar to setting the default for the listings.
  4. logic to change the "N attachments" link below a teaser. It shows:
    1. nothing when there are no attachments that are only listed on the node
    2. "N attachments" when there are no attachments listed on the teaser
    3. "N more attachments" when there are attachments listed on the teaser and other or more are listed on the node itself.
Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new8.4 KB

Chasing head after file-objects-change. I t took surprisingly little effort :)

cburschka’s picture

Status: Needs review » Needs work

1. When building a form array, the occasional blank line between individual field arrays greatly improves readability. Instead of deleting the one that was there before, it might be better if you put one on each end of your new field declaration.

2.) You missed a space after the first comma in the db_add_field() call in upload_update_7000().

3.) For consistency, call it $num_files_teaser instead of $files_on_teaser (num because it's a counter like $num_files, drop the "on" because prepositions just unnecessarily bloat the variable name).

4.) Long boolean expressions are pretty daunting. I don't see any obvious way to improve this one (except maybe by dropping the superfluous parentheses around AND statements). The next best thing is an inline comment to explain what's happening.

if (((!$teaser && $file->list) || ($teaser && $file->teaser)) && empty($file->remove)) {
maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new8.74 KB

Thanks for your review. I agree with all of your remarks, and implemented them accordingly.

Still no functional change since #3, so the screen shot there is still valid.

cburschka’s picture

Status: Needs review » Needs work

This looks great!

However, I see a tiny problem when testing this. Steps to reproduce:

1.) Upload a file.
2.) Check teaser.
3.) Upload another.

Teaser checkbox gets unchecked...

Edit: I've looked through the ahah code a bit, but I don't see any obvious problem. Yet list and delete remember their values, and teaser does not.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new8.74 KB

I entered 'value' instead of 'values' in upload_js(), causing the checkbox to always fail. This shows that this needs tests.

Attached is with the fixed 's', but without tests.

maartenvg’s picture

StatusFileSize
new10.36 KB

Now with extra tests. Of course, this can't test the upload AHAH calls, so the bug that was fixed in #9 can't be tested for future breaking.

maartenvg’s picture

StatusFileSize
new10.36 KB

It seems the retesting is broke. Lets try uploading it again.

catch’s picture

Component: upload.module » usability

Moving to usability queue - also, can we have a screenshot of the attachments + the UI for uploads?

maartenvg’s picture

You mean like the screen shot in #3? http://cdn1.drupal.org/files/issues/247071_show_attachments_on_teaser.png

Or do you want a screen shot of the attachments in the teaser? Because that UI/layout is identical to the attachment listing in a full node.

catch’s picture

Whoops, just like that one.

Status: Needs review » Needs work

The last submitted patch failed testing.

rafal_p_s’s picture

Status: Needs work » Needs review

upload.admin_.inc_.patch queued for re-testing.

rafal_p_s’s picture

upload.module.patch queued for re-testing.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.