A response in posting 'http://drupal.org/node/419404' suggests using the CCK.module with the filefield.module to implement file download functionality. I worked through a number of CCK examples and videos but still do not understand how to add file download functionality to a page. Can anyone explain how this is done? I would appreciate any suggestions, documentation and/or videos that illustrates how to use CCK and/or any other module for adding file download functionality.

What I am trying to do is to display the names of 5-10 documents and allow the user to download the documents simply by clicking on the document name. One approached was to used the 'upload' module as described in the response to my first posting (http://drupal.org/node/486856) on the topic of file downloads. However, the list of document names is only displayed after clicking on the 'attachements' field. I want the list of document names to appear on the page when it is first displayed - hence my efforts to use CCK to find a solution.

Thanks for your time.

Ian

Comments

kuldip zala’s picture

Hi,

Add filefield as a CCK. Then maka one view from admin/build/views using Views module according to your requirement.
Then click on 'fields' and add your cck field. In that select that field as Generic files.

Thanks,

ian00bell’s picture

Sorry, I just edited this post after realizing that point #1 below was not previously added.

I've unsuccessfully tried the following. Can you point out what I am doing wrong.

1) create a new content type, adding a single field with the type 'File' and operations 'File Upload'. The field file path has been set to 'sites/all/files' where the document files are located.
2) add a view, selecting the 'File' view type
3) in the 'Views User Interface' add a 'Page' display then click on 'Defaults' so that the default settings will be defined
4a) for 'Add Fields', select 'File' from the Groups dropdown box then check off 'File: Name' and 'File: Path'.
4b) to configure the 'File: Name' - set the 'Label' to the name of the document, click on 'Update'.
4c) to configure the 'File: Path' - delete the default 'Label' so this field is empty, check the 'Link this field to the download file', click on 'Update'

At this point I am expecting the view to allow me to select/link to the file that is to be downloaded, but this is not the case. I do not see anything that indicates a 'cck filefield' is in use. Instead the error message 'Display "Page" uses a path but the path is undefined'. Presumably the path should reference the file that is to be downloaded but, if so, then it is not clear to me how to define this path.

thanks,

Ian

ian00bell’s picture

Hello Kuldip,

Thanks again for your suggestion.

I don't understand why a view is necessary in the first place. Conceptually, all I am interested in doing is using CCK to build a new 'content type' page which contains fields for downloading specified files. These files are specified at designed time (i.e. they are not dynamically determined at runtime). The question is, how can I associate a document filename with a CCK filefield so that this document is downloaded when the user clicks on the label?

Now with regards to views, my understanding is that they dynamically query the database for information at runtime and this information is then added to the CCK field(s). But the names of my documents are not stored in the database. Instead, my documents are located in the directory 'sites/all/files'. So I do not see how a view will be of much use.

Part of the problem in this matter is that the Drupal documentation on 'filefield' is sparse and what is provided is useless (this is typical of a lot of Drupal documentation). Obviously my trial-and-error approach has been unsuccessful and (like many Drupal'ers have posted) I'm getting rather frustrated in trying to implement something as simple as a file download.

Can you provide a more specific, step-by-step description of what you have proposed for implementing a file download?

Thanks,

Ian

mradcliffe’s picture

IIRC, CCK fields should be displayed when viewing a node. This includes filefield, and it displays it as a link to the file.

No need for views. Just add your files when creating a node, and then they'll show up when you view them along with any other CCK fields. Unless you've enabled field-specific permissions.

(just tested this on one of my dev sites)

ian00bell’s picture

Thanks mradcliffe. With your suggestion and a bit more fumbling around, I finally managed to get this to work.

Learning Drupal could be made so much easier and less time consuming if the module developers took the time to provide adequate documentation and examples.

Cheers,

Ian

WorldFallz’s picture

Anyone registered on d.org can contribute documentation and examples. In general, developers work with code, not text and that's what they're good at. There are over 500k registered users on drupal.org-- even if only a tiny fraction of those accounts are real, there's no excuse for lack of documentation except for the lack of participation on the part of the user community. Blaming "module developers" for that is absurd. I see tons of people in the forums and issues pining over the fact they can't code so they can't help. Documentation is the one thing anyone can contribute-- regardless of their skills.

Developers develop-- any user who has had to figure out how to use a module is capable of contributing that knowledge back. And in fact, I would argue that a user is far more likely to document something in the best way for other users. Many times in my experience, when developers do write documentation users complain it's not basic enough, lol.

codeangle’s picture

In response to my fellow new drupal user! Let us take the initiative and compile all these tried and tested solutions on forums/blogs, disseminate them and republish them somewhere. The developers are engaged in refining drupal, we newbies can contribute by taking on the mantle of documentation. Look be smart, this will bring you closer to developers and speed up your status in the drupal community; I guess this is what we all want. To improve open source. I think it is naive to moan about documentation in open source, Gates is laughing at us; help wipe the smile off his face.

WorldFallz’s picture

excellent!