Difference between revisions of "Drupal file list"
m |
m |
||
Line 41: | Line 41: | ||
When you're finished, save the view. You should be able to access your list at: | When you're finished, save the view. You should be able to access your list at: | ||
− | {Your [[Drupal]] URL}/?q=view/files | + | {Your [[Drupal]] [http://en.wikipedia.org/wiki/Uniform_Resource_Locator URL]}/?q=view/files |
==Adjusting A View's Theme== | ==Adjusting A View's Theme== |
Revision as of 12:19, 29 February 2008
How To Create A Taxonomy Based File List In Drupal
This page will guide you in setting up a list of uploaded files in Drupal. Hopefully the information contained in this tutorial will be as deep as Drupal's learning curve is high (if ever that were possible).
Create File Content Type
To begin, you should have administrative privileges and the Views and Taxonomy modules should be installed.
Bring up your Administer menu and navigate to Content Types under the Content Management category. We need to create a new content type to hold our uploaded files, so click Add Content Type near the top of the screen. Under the Identification tab, name the content type 'File' of type 'file' and write a brief description such as, "A node to hold an attached file." Skip the Submission Form tab. Under the Workflow tab, make sure that the Default Comment Setting is set to 'Disabled' and Attachments are enabled. Save your new content type.
Cool, you've created a content type to hold your uploaded files.
Creating And Populating A Vocabulary
We are about to define a list of terms (a vocabulary) to define our new File content type.
Adding A New Vocabulary
Return to the Administer menu, navigate to Categories, again under the Content Management category, and click on Add Vocabulary near the top of the screen. Name your new vocabulary 'File Type' and add a description such as, "Different categories of files." The Types option box should only recognize the content type 'File' and term Hierarchy should be disabled. Before saving, make sure you check the Required option, so that every File content type will have an associated word in the vocabulary. Go ahead and submit your vocabulary.
Generating Terms
Now that we have created a vocabulary, it will show up on the Categories page under the name 'File Type'. To populate the new vocabulary, click the Add Term link under the 'File Type' tab. Give the term a Name and a short Description before submitting it. You can repeat this step to add any other 'File' terms to your vocabulary. Once finished, you can click List Terms under 'File Type' on the Categories page to view or edit the terms you have added to the vocabulary.
Creating A List View
Now that we have created a 'File' type to hold our files and a vocabulary to group them, we must make a View to display them.
Defining The View
Return to the Administer menu and click on Views under the Site Building category. There should already be a few views listed, but we want to create a new one. Click on Add near the top of the screen. Name your view 'file_view', define the view's access levels, and add a short description such as, "Lists all file content types." Under the Page tab, check Provide Page View, give the view a URL such as 'view/files', and select 'List View' from the drop-down box under View Type.
Defining The Fields
Under the Fields tab, we need to create three fields to sort the data. From the Add Field drop-down box, select 'Node: Title' and click Add Field. Now that the field has been created, we need to adjust its settings. Under Option select 'As Link' and under Default Sort select 'Ascending' when the new field appears in the Fields table. Create two more fields, a 'Taxonomy: Term' and a 'File: Name', and set their Handler drop-downs to 'With Link' and 'With Download Link', respectively.
Defining The Filters
Under the Filters tab, we need to create a filter that lists our files by their vocabulary word. From the Add Filter drop-down box, select 'Taxonomy: Term' and click Add Filter. Now that we have created the filter, we need to adjust its settings. Under Operator select 'Is One Of' and select all 'file' Values that need to be displayed.
When you're finished, save the view. You should be able to access your list at:
{Your Drupal URL}/?q=view/files
Adjusting A View's Theme
Almost there! Now that we have a content type, vocabulary, and view, we need to adjust the view to display the files by their vocabulary word and node name. To do this, we'll have to deal with PHP code that will tell the theme what to display.
Generating The Code
Return to the Views page, by way of the Site Building category on the Administer menu. You should see your view listed in the Existing Views table. To modify the theme, click on the Theme Wizard link near the top of the page. Select your view's name in the Select A View drop-down box ('file_view', in the case of this example), select Theme Type 'Grouped List', and click Select Theme Type. From the Field On Which To Group box, select 'term_data_name' and click Generate Theme. You should see three text boxes containing code that will be added to your Drupal theme folder.