Download Manager
Conclusion
Tue, 11/25/2008 - 19:49 — chadWell, that should help to have something similar to DOCman in Drupal using common modules. It took us a little while to get to this point, and it isn't quite as powerful, but it does the job nicely.
You don't have to implement your download manager in the same way as I described. Feel free to add/remove fields from the nodes, use a different layout, etc. The possibilities are endless!
--Chad
Customizing the CSS
Tue, 11/25/2008 - 19:44 — chadAll that's left to do now is to create CSS styles to control to look of the download nodes. This is where a browser add-on, such as "Web Developer" for Firefox comes in quite handy.
Layout the Node's Fields
Tue, 11/25/2008 - 19:33 — chadWe are coming along. So far, we can theme the download nodes as we like, but the layout isn't quite how I'd want it. We need to create a new template file named views-view-fields--<view_tag_name>.tpl.php, or views-view-fields--downloads.tpl.php. Note that I changed the name for the view tag to "downloads" as opposed to the singular "download" that we used for the node type. This isn't necessary, and you may keep them consistent. This file is actually a copy of views-view-fields.tpl.php, which is located in the modules/views/theme
Copy node.tpl.php to node-downloads.tpl.php
Tue, 11/25/2008 - 19:16 — chadJust as we copied page.tpl.php to page-downloads.tpl.php, we need to do the same for the node.tpl.php file. Actually, the modification is very minor and easy to miss. In the first div, change the name of the class from "node" to "downloads-node". In other words, change the line from
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
to
Copy page.tpl.php to page-downloads.tpl.php
Tue, 11/25/2008 - 19:10 — chadWe need to specify a custom template for download pages. Make a copy of the template file "page.tpl.php" and rename it to "page-<node_type>.tpl.php," where <node-type> is the name we gave to the node type when we created the content type. In our case, we would name the file page-download.tpl.php.
Open the new file in a text editor. Around line 69 (just after the mission) add a new line and add
Modifying Code Template Files
Tue, 11/25/2008 - 18:49 — chadBy default, any styling we try to perform on the download nodes will affect all other nodes as well. This probably isn't what we had in mind, so let's correct that.
Note: In this tutorial, I am using the standard Garland theme, but the process should be the same for others.
Setting up the Downloads Node and View
Tue, 11/25/2008 - 18:20 — chadThe most important thing to do in order to create the download manager is to create a node and view for the download content type. This section will cover the technical aspects of the setup, and is essential to having this work. In fact, this section alone will create a working download manager, but it won't have the visual appearance of DOCman yet.
Theming the Download Nodes
Tue, 11/25/2008 - 18:16 — chadIf you've been going in order, the "Downloads" node is up and essentially working. It just doesn't look like you might expect it to just yet. This next section will delve into how to theme the downloads, allowing you to essentially duplicate the DOCman appearance.
Since we want the download nodes to have their own styling, we will need to make some changes to the template files to allow specific templates for a view.
Add Some Download Content
Tue, 11/25/2008 - 18:12 — chadAt this point, you should have a menu item for your newly created downloads view. However, if you click on it, you will see the "Downloads" title, and nothing else. Let's go ahead and add some sample content.
Go to Create content->Download. Enter a title for the download, and give it a description. Under "File Name," browse for the file you want to add, and upload it.
Save the new entry.
Create the Download View and Add to Menu
Tue, 11/25/2008 - 17:19 — chadAssuming we want to have the download manager accessible from the menu, we need to setup a view for the content type. Go to Administer->Site Building->Views, and click "Add" at the top of the page. Enter a name (ie. "downloads") and (optionally) a description ("Collection of files available for download") and a tag ("downloads") for this view. Leave the type as "Node" and click "Next."
We now have a fairly complicated looking page. Don't despair, we'll get through this.