Drupal documentation

From Stadm
Jump to navigationJump to search


Documenting procedures on using Drupal to create the new ERI website

Creating News Items and a News List

  • Drupal does not have existing news content type
  • Need a content type for Date and PI
  • use View to format blocks and pages

The steps I followed:

  1. Create a content type of 'news'
    1. Login as Site Admin
    2. Go to Structure/Content Types, click "Add content type"
    3. Name: News, Type: news (try to use all lower-case for the type), Description: News articles submitted by administrative students
    4. Workflow setting: Check 'Published', Disable 'Comments'
    5. Save the content type
  2. Add custom fields
    1. click on 'Manage Fields'
    2. Add in specific field labels and names for 'News', in this case, I created 3 custom field types: Date, PI, URL
    3. You can set the size of the text field and whether it is required or not
  3. Add some news
    1. click on 'Create Content' link and create some news items
  4. Create the default view in the VIew module
    1. go to Adminster/Siting building/Views
    2. click add to create a new View
    3. View name: News_list, View description: listing of recent news, View tag: News, View type: Node, Click Next
    4. Click on the '+' sign next to Fields. Scroll down and select Content: Date, Node: Title, Content: PI and click on the add button.
    5. For Content:Date, select Widget label (Date), and leave the rest to default
    6. For Node:Title, remove the label of 'Title' (clear the text). Check the box 'Output this field as a link' and check 'Link this field to its node'
    7. For Content: PI, select Widget label (Date), and leave the rest to default
    8. Click the '+' sign next to Filters. Check Node: Published and Node: Type. These options let us choose to display only Published content (Node: Published=Y) and only news (Node: Type='news') then click add
    9. For Node:Published, click 'yes' for published item
    10. For Node:Type, select 'Is one of' and check 'News'
    11. Now let's sort the news items by most recent first (descending order) Click on the '+' sign next to Sort criteria
    12. Check Content:Date and click add
    13. Select descending and click update
  5. Create the page view in the View module
    1. Select page under the Defaults and click Add Display
    2. In the Basic setting, change the Name to news_page, Title; Recent News, Style: Table, Item to display: Unlimited (type 0)
    3. Then check sortable for Fields: Date, Title, PI and select the Default sort to be Date
    4. Check 'Override normal sorting if click sorting is used' and select Default sort order to be Descending
    5. In the Page setting, make the changes to 'Path: news' and 'Menu: Normal: news' and select Menu to be Primary Links
    6. Click update and save
  6. Create a block for the most recent 5 news to display on the homepage
    1. Select block under the Defaults and click Add Display
    2. In the Basic setting, changethe Name to news_block, Title; Recent News, Style: Table, Item to display: 5, More Link: Yes
    3. click update and save
    4. Go to Site Building/Block,
    5. Scroll down to the list of inactive blocks and find the one named ‘news_list: news_block’. This is what we created when we built our view in the previous steps. Click on the dropdown box and select ‘content bottom’ (depending on where you want to place the block).
    6. Click on configure for 'news_list: news_block'. Scroll down to ‘Page specific visibility settings’ and click on ‘Show on only the listed pages’ and type <front> in the text box.
    7. Click the ‘Save blocks’ button at the bottom of the page.

Panel issues

  • inserted images did not show up
    • fix - need to select "Full Html" rather than "Filtered Html" in "Input Format"

Custom fields of content type issue

  • the custom fields of a content type did not show up when I tried to create a new content of this content type
    • fix - need to enable permissions of these fields in the User Management-Permissions

Change the layout of the node display page

  • Suppose you want to display data, PI and URL on top of a new node rather than the bottom, how can you achieve that?
    • A simple way - just to go Content management/Content types/ and click on manage fields on the content type of the nodes you want to change layout, click on the cross symbol next to the fields that you want to change orders and drag them to their new order of display locations. However, this will not only change the fields' view order, but also the fields' input order.

Making fields such as URL clickable

  • The trick here is to select the right format for the field. Go to Content management/Content types/Manage Fields/Configure. For make URL clickable, you need to select the Widget type of the field to be 'Text Area (Multiple rows)' rather than just 'Text field'. Then , you need to select 'Text processing:' to be 'Filtered text (user selects input format)'. Now when you paste an URL in the field location, Drupal will automatically convert the link to clickable.

In View module, Link field contents to clickable URL

  • This solved the issue of making the title of the articles in the news linked to the URL of the news source
    • In the fields section under the View module, add Content: URL ( or whatever you need to link to ) and make sure it is on top of the field that you are trying to change its link path to. You can select 'Exclude from display' for the 'Content: URL' not to show up. Then, click on the field that you want to change its link path to the 'Content: URL' and check 'Output this field as a link' and make sure 'Link this field to its node' is not checked. In the Link Path, copy and paste the associated Drupal path of 'Content: URL', for example, [field_news_url_value]. You can find the translation in the 'Replacement Patterns'. Click update then save and you should see the field you selected is linked to the address of the URL field.