Monday, February 25, 2013

What is Drupal components and how do they work?


Drupal Components are the things that make up the robust content management system and content management framework. Drupal Components mainly include node, modules and themes. In Drupal almost every content is a node.

1. Node

The main building block of Drupal is a node. The word ’node’ does not suggest that it is a part of some network. On the contrary, you should think of a node as a single puzzle piece that is placed onto the site by one of your users, or even yourself. A node can be part of a forum, a blog or a book, and by using the Content Construction Kit, you can create as many custom node types as you want. Remember that each node has a type, referred to as a Content Type. It also has a Node ID, a Title, a Body, a creation date, an author and some other properties. It is stored together with all other nodes in one big shoebox known as a "table" in your database.

Drupal has many tables, I think the core has some 50 of them. You may want to explore them on your own site to get a better idea.

Users have their own table too, and some of them are authors of nodes. So nodes do have relations. The only way to find those relations is by searching the whole table until you find all matching items. Luckily the database server is very fast.

Each node can have an unlimited number of comments. Comments are stored in a separate table. To find all comments on one node the server will search the entire comments table.

How do Nodes work?

Look at the address bar of your browser. It probably says "http://drupal.org/node/19828". This is the Drupal way of saying "Load all pertinent information for node 19828, including whatever relations (comments, users etc.) are to be shown". This is called a database query.

Most queries in Drupal are hard-coded in modules. /tracker searches all nodes and sorts the result by date. This also works for your site, as long as you enabled the tracker module.

When you hover over the menu and meanwhile read the links in the status bar you get a quick idea of possible queries. Because Drupal mimics a directory structure you maybe didn’t know it was a query until now!

Drupal modules perform a lot of operation on the data. For instance when you open a page which you have written yourself you see a view/edit tab on top of the page. This tab is not shown on other pages. This is automated behavior defined by the user privilege settings.

Drupal stores all of its content in nodes. Drupal’s basic set of node types is relatively short, but quite flexible.

Blog Entry

Blogs, or weblogs, are another term for an online journal or diary. They are a place where members of the community can write their own thoughts and not have to worry about being on topic for the site.

Book Page

Book pages are designed to be part of a collaborative book. An example of a collaborative book is the Drupal developer documentation. Originally only book pages could be a part of a book but these days all node types can be part of a book.

Comment

Comments actually aren’t nodes, they are their own special content type. Comments are what allow people to add comments to any other node that has been created.

Forum

Forums are sets of nodes and their comments. These are grouped together as belonging in one forum by assigning them the forum name, which is a taxonomy term. These forum names can be grouped in forum containers, which are other terms, of which they are children in a hierarchical vocabulary which is called "forums", and configured as only applicable to nodes of the "forum" type.

Page

Pages are simple nodes, typically used for static content that can (but are not required to) be linked into the main navigation bar

Poll

A poll is where a multiple choice question is asked and users can answer and see other people’s answers to questions.

Story

Story pages are the generic page type that most content management systems have. Stories are generally used for information which is only relevant for a period of time (eg. news stories) and is expected to expire off of the page. Additional types of nodes are provided by contributed modules.

Note: A common question is "What is the difference between page and story?" The answer is not much. There was more difference originally but they are merely different node types now and how you use them is up to you.

2. Content

Once you have logged-in, you’re ready to start posting content. At the top of your personal menu, you’ll find a link called "create content". Click this and you’ll see a list of the types of content you can create. This list reflects the privileges assigned to your user account or to the group ("role") your account is part of.

There are several contributed modules which can assist with more complex content creation within this framework, such as spell checking, image embedding, and file attachment uploading.

2.1 Page

The page module allows users to create static pages, which are the most basic type of content.

Pages can be collected in books via the book module. Users should create a page if the information on the page is static. An example would be an "about" page.

When a page is created, a user can set authoring information, configure publishing options, whether readers will be able to post comments. They can also select the content type of the page (e.g., full HTML, filtered HTML, php).

As an administrator, you can set the publishing default for a page (in its workflow): you can specify whether a page is by default published, sent to moderation, promoted to the front page, sticky at the top of lists, and whether revisions are enabled by default. You can set the permissions that different user roles have to view, create, and edit pages.

2.2 Story

The page module allows users to create static pages, which are the most basic type of content.

Pages can be collected in books via the book module. Users should create a page if the information on the page is static. An example would be an "about" page.

When a page is created, a user can set authoring information, configure publishing options, whether readers will be able to post comments. They can also select the content type of the page (e.g., full HTML, filtered HTML, php).

As an administrator, you can set the publishing default for a page (in its workflow): you can specify whether a page is by default published, sent to moderation, promoted to the front page, sticky at the top of lists, and whether revisions are enabled by default. You can set the permissions that different user roles have to view, create, and edit pages.

3. Menu and Menu System

Menu’s are displayed in blocks. Blocks are the columns at the left and/or right site of your web page. First be sure to enable the menu module (blocks module is always enabled). You will get a menu item in the admin menu.

All modules come with default menu items. Often you only will need to enable them. You can change its location in the menu tree by setting its parent and you can change its title if you wish. In all cases it will only show up when you have rights to view the content. E.g. the admin item is not shown to visitors.

You can also create custom items (add menu item tab). You will need to provide a path to the content. Go to the page you want to link to (e.g. via recent posts) and look at the address bar.

By default the address next to the domain name will begin with ’?q=’. When ’clean URLs’ is enabled you will see a directory structure. Anyway, you need to copy-paste the right part of the address without the domain name and without the "?q=". This is called the local or relative path. (But as I mentioned, it’s a database query mimicking a directory structure.)

By the way, if you change your settings to ’clean URLs’ you may also want to change the "default front page". That can be your forum main page ’forum’ or a custom made page ’node/15’.

’Navigation’ is the default menu, but you can create more as you like. You will need to activate a menu in the blocks settings to tell if, and also where, you want those menu to be displayed. Next you can move menu items to it by changing the item’s parent property.

You also can create custom blocks. You can type the html code yourself so you have complete freedom.

You will soon discover the menu’s and blocks will not give you all you need. The main problem is that a menu item can point to a single node or to a list of nodes of one type, organized by date. In other words, you only can create links that have a fixed meaning, defined by the modules. And you want more of course! For that reason you will need modules that create structure. Examples are:

- books
- stories
- search
- taxonomy
- archive

4. Themes

Drupal takes great care to keep the elements of content and its presentation of a site separate.

This allows you to come up with multiple designs for the same content. These designs are called themes. Each theme can consist of one or more files that work together to present the content of your site in a unique way. Drupal has four themes available as part of the core download, and many more available in the contributions repository on Drupal.org.

To see themes in action, navigate to Administer >> Site Building >> Themes or to Appearance (Drupal 7, later).  This page presents a list of all the installed themes. You can enable them individually by checking the Enabled check box, and you can choose one to be the default theme. Drupal allows registered users to choose which theme to use from among the enabled themes. That user will then experience the site in the theme of their choice. If you want your site to be viewed in only one theme at all times, leave only one theme enabled.

5. Modules

A fresh installation of Drupal has only a small fraction of the available functionality enabled.

The most common way to enhance Drupal and add functionality is through modules. Drupal comes with more than 30 modules installed, but most of them are disabled by default.

To see a list of available modules, navigate to Administer >> Site Building >> Modules or to Modules (Drupal 7, later). All of the modules listed on this page correspond to individual files in the /modules directory in your Drupal installation. You can enable them simply by checking the Enable check box and clicking Save Configuration.

5.1 Blog

The blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal or diary. Blogs are made up of individual posts that are time stamped and are typically viewed by date as you would a diary. Blogs often contain links to webpages users have read and/or agree/disagree with.

To get started with the Blog module, you need to assign the Edit Own Blog permission to the user roles that should be able to maintain individual blogs. Users with the proper permissions can then create new blog entries using the Create content >> Personal blog entry link. You can categorize blog using the taxonomy module. Additionally, blogs can have file uploads, store revision history, be promoted to the front page, and have comments.

5.2 Poll

The poll module lets you create simple polls. You ask a question, provide possible answers, and let your users vote. All votes are counted, and the running results can be seen represented as a bar graph.

To create a poll, activate the Poll module and go to node/add/poll. Give your poll a title that explains it, and then enter a number of choices. You can set the initial votes to something other than zero, if you have a reason to do so. If you need more than five choices, check the Need More Choices box and then click Preview. You will be given five more choice fields. The Poll Duration field lets you set a time frame for the poll to be open to voting, after which the poll will be closed and voting will no longer be possible.

On the access control page (Administer >> Access control) (or People >> Permissions for Drupal 7) you can decide which users have permission to vote, to see the voting results, and to create polls of their own.

6. Blocks

A block is a unit of content that you can place in the various regions of the layout. Blocks can do many different things. The login fields and the main navigation menu are each blocks, for example.

To see the list of available blocks, navigate to Administer >> Site Building >> Blocks or to Structure >> Blocks (Drupal 7, later). The table on the blocks page lists all of the available blocks by region, or under Disabled for those blocks that are not yet turned on. You can enable any of the disabled blocks by checking the Enabled check box and clicking Save Blocks. You can also change the region of the screen where they appear. You have the choice of right or left sidebar, header, footer, or content.

Blocks are generally provided by modules, which means that as you enable or install more modules, more blocks will be available.

An administrator defined block contains content supplied by the administrator. Each admindefined block consists of a title, a description, and a body which can be as long as you wish.

The Drupal engine will render the content of the block.

No comments: