| 1 |
/**
|
| 2 |
* $Id:$
|
| 3 |
* @package CCK_Download_Dropdown
|
| 4 |
* @category NeighborForge
|
| 5 |
*/
|
| 6 |
This module adds the ability to place a single drop down selector and download button
|
| 7 |
on a node for use by the viewer. The list is populated by links to attachments from a
|
| 8 |
node that you specify. Selecting an attachment and pressing the download button will
|
| 9 |
initiate a download of the selected file. Although multiple drop downs in a single
|
| 10 |
field are not supported, you can add multiple fields, each with a drop down populated
|
| 11 |
by different files.
|
| 12 |
|
| 13 |
--CONTENTS--
|
| 14 |
REQUIREMENTS
|
| 15 |
INSTALL/SETUP
|
| 16 |
FEATURES
|
| 17 |
USAGE (Example)
|
| 18 |
UNINSTALL
|
| 19 |
CREDITS
|
| 20 |
HELP
|
| 21 |
|
| 22 |
--REQUIREMENTS--
|
| 23 |
*************************************************************************************
|
| 24 |
IMPORTANT!!! - You need to supply an icon, call it disk.png, and place it in this
|
| 25 |
module's folder. The one I use wasn't GPL-compatible so could not be included in this
|
| 26 |
release. The one I use looks like a floopy disk, but you could use anything.
|
| 27 |
*************************************************************************************
|
| 28 |
|
| 29 |
This module depends on the upload module that comes with Drupal by default. In the
|
| 30 |
future, other file managers may be supported. For now, we're looking for attachments
|
| 31 |
to nodes as specified by the upload module.
|
| 32 |
|
| 33 |
This module also depends on the content module.
|
| 34 |
|
| 35 |
--INSTALL/SETUP--
|
| 36 |
Copy entire folder and contents into your modules folder in your Drupal installation;
|
| 37 |
usually this is sites/all/modules.
|
| 38 |
|
| 39 |
Activate the module.
|
| 40 |
|
| 41 |
--FEATURES--
|
| 42 |
Present users with a drop down list of attachments instead of a table.
|
| 43 |
|
| 44 |
Have multiple drop downs on a single page, each with its own list of files. This allows
|
| 45 |
you to have one drop down per file category.
|
| 46 |
|
| 47 |
Order the file list either in ascending or descending order.
|
| 48 |
|
| 49 |
Made more for use by admins, not end-users since there are a few caveats to beware of.
|
| 50 |
|
| 51 |
--USAGE--
|
| 52 |
1) The first thing to do is to create a regular page and attach a bunch of files to it
|
| 53 |
like normal. I suggest creating several such pages, broken down into categories. An
|
| 54 |
example of why you would do this is if you have a ton of MP3s you want to allow users
|
| 55 |
to download. Create one page for each category, and title it with the category name.
|
| 56 |
Leave the body empty as you won't see it in conjunction with this module. You will
|
| 57 |
still be able to allow users to view the pages if you want, but you could also leave
|
| 58 |
the nodes 'unpublished' so as to be unreachable themselves.
|
| 59 |
|
| 60 |
2) Create a new content type. Title it MP3 downloads for the above example. Fill in the
|
| 61 |
body with a description of the categories that follow and maybe your own download
|
| 62 |
instructions which paraphrase what I'll tell you below.
|
| 63 |
|
| 64 |
3) Add a new field to the new content type you just created. Give it an appropriate
|
| 65 |
machine language name, and select this module's 'cck_download_dropdown' type for the
|
| 66 |
field. Submit the form. On the next page, title the field the same as one of your
|
| 67 |
categories you identified (page title(s) from step 1). I suppose you could make the
|
| 68 |
field REQUIRED, but I don't know why you would. Select which sort order you would
|
| 69 |
like the drop down to have. This assumes that you know what files are named ahead
|
| 70 |
of time. The default is ASCENDING. I put in the option for DESCENDING because I am
|
| 71 |
listing files named by date such as 2007.10.06.Filename.pdf and I wanted the newest
|
| 72 |
to be at the top.
|
| 73 |
|
| 74 |
4) Repeat step 3 for each category you identified/page you created in step 1.
|
| 75 |
|
| 76 |
5) Weight the fields as you wish them to show up. You may want to use the fieldgroup
|
| 77 |
module if you have a lot of catagories (fields) so that you can ensure they are below
|
| 78 |
the body and then ordered correctly. It seems the body is weighted at 0 and you can't
|
| 79 |
change it, so weighting the others only gives you ten spots heavier than the body. So
|
| 80 |
should you have more than 10 categories/drop downs, you won't be able to give them
|
| 81 |
unique weights without the fieldgroup module.
|
| 82 |
|
| 83 |
6) Create a new page using your new content type. Each field created with this module
|
| 84 |
should present you with a drop down list of all nodes' titles where you uploaded docs
|
| 85 |
via the upload module (i.e. have entries into the 'files' table in your database).
|
| 86 |
If you named the category nodes by the category name, and if you named the cck field
|
| 87 |
the category name as well, then you should just have to match the node name with the
|
| 88 |
field name. NOTE: the use of the word 'category' has nothing to do with the taxonomy
|
| 89 |
module - I'm using it in the real-world sense.
|
| 90 |
|
| 91 |
7) Match all of the other fields to nodes, then submit the page (after filling in anything
|
| 92 |
else you may have added as fields to the node).
|
| 93 |
|
| 94 |
8) Now when you visit the page, you'll see several drop down lists of files (MP3s in our
|
| 95 |
example), each with a download button or icon next to it. If you see the icon, then
|
| 96 |
you have javascript enabled. This image is simply a link to the currently selected file
|
| 97 |
in its associated drop down list. If you select a new item, the link will change. This
|
| 98 |
allows users to download as many documents as they want without leaving the page.
|
| 99 |
|
| 100 |
9) If javascript is not enabled, instead of a download icon, a regular form button will
|
| 101 |
display. Hopefully it works, but I admit it isn't as tested as the js solution. What
|
| 102 |
should happen is that a user selects a file from any drop down, then clicks the button.
|
| 103 |
They will be served that document, replacing the current page if the document can be
|
| 104 |
opened by the browser. I couldn't figure out how to get drupal_goto() to serve a page
|
| 105 |
in a new window. I am not sure what happens when the doc can't be viewed inside the
|
| 106 |
browser. I would imagine that the browser will ask you if you want to download via
|
| 107 |
a popup. The page will either return to the download page, or will be blank, in which
|
| 108 |
case the user will have to browse back. If anyone has ideas how to make this part work
|
| 109 |
better, I'd love to hear it.
|
| 110 |
|
| 111 |
--UNINSTALL--
|
| 112 |
This module does not install any of its own tables into your database, nor does it use
|
| 113 |
its own variables in the variables table, so there is nothing to uninstall if you
|
| 114 |
ever choose to deactivate this module.
|
| 115 |
|
| 116 |
--CREDITS--
|
| 117 |
This module was created by Ryan Constantine (rconstantine) Nov 20, 2007
|
| 118 |
|
| 119 |
--HELP--
|
| 120 |
Not for you, for me-
|
| 121 |
If you have ideas for this module and especially if you can make patches,
|
| 122 |
please do. I'm open to any improvements.
|
| 123 |
|
| 124 |
For you-
|
| 125 |
you can post questions, comments, and patches to the issue queue for this module on
|
| 126 |
the Drupal.org web site.
|