Categories
CMS Drupal

Create a block listing some content type

First, the views module is needed:
http://drupal.org/project/views

After having the views module installed, we can go with an optional install of advanced_help module which provides the help I used to accomplish the subject of this article.

So, after having the prerequisites, we can proceed with adding a view which will provide a block for listing a specific content type or even more than one types, specified by filters.

Create the content type

I’m gonna describe the whole process, including the creation of the type that will be listed in the block.

  • Navigate to admin/content/types.
  • Choose Add content type.
  • I’ve filled the following values, creating a type called Publication, which I use to unite all type of publications that I needed to be included in the block with the listing, called What’s New.
    – Name: Publication
    – Type: publication
    – Description: Posts of type Publication (releases, articles, tutorials, etc.) 
  • Save.

Create the catgeories for the Publication type

Next thing is to add a new taxonomy vocabulary, which will include all the terms (categories) that will be presented by the Publication content type. So, go and add vocabulary called (surprisingly) Publications and add the following terms to it:

  • Articles Category
  • News Category
  • Releases Category
  • Tutorials Category

These are the categories that will be listed in the What’s New sidebar block.

Ok, so we can now fill some test or real world content before proceeding to the next step:

Create the view

It’s time now 😉

  • Go to admin/build/views
  • Choose Add
    – View name: whats_new_view
    – View description: The view for displaying what’s new items
    – View tag: whatsnew_view_tag
    (I tend to name the variable I don’t what will be used for, similar to their description, so when I meet a loooong variable with super descriptive name, I know which variable was that 😉 )
    – View type: Node
  • Next
  • Please, not on the left column of the next screen, we have a display called “Default” and a button below it, that will allow adding the following displays: Page, Feed, Block, Attachment
  • First, we need to fill the default values and then we will add the block display. This is done in this order so to be able to provide default values that all added displays will inherit.
  • Basic settings, Relationships, Arguments: leave as it is.
  • Filters: Add filters:
    – Node: Published = Yes
    – Node: Type = Publication
  • Sort criteria:
    – Node: Post date = DESC
  • Fields:
    – Node: Title (delete the label and check the option “Link this field to its node”)
    – Node: Post date (delete the label and choose Custom date format: (M j, Y), this will display the dates like this: (Sep 25, 2011) )
  • Update
  • Add display Block

    Important Note: Be careful when updating not default display, that you have to override the setting that you want to change, prior to updating it. If you don’t override the setting, then the default setting will be changed, which will result in a chained update of all the displays that inherit from the default.
  • Save the view.

Instruct Drupal to show the block

Finally, you should tell Drupal to show this block. Configure your block by going to admin/build/block. Locate the block in the list: it is labeled What’s New. Place this block in a region and click Save. You may click Configure to set a different title, to determine which roles can view the block, and on which pages it appears; If you want your block on the front page only, enter ‘<front>’.

Note: if you want to have a link like “more” or “read more” in the What’s new block, you have to add a display of type Page to the view and for its Page setting > Path set: category/publications/%

Categories
CMS Drupal

How do I get rid of the “Welcome to your new Drupal website” on the front page?

I will add to this article all usefull and intuitive to answer to topics, related to Drupal.