Home » DRUPAL » Tutorials for Drupal

Tutorials for Drupal

tweetme

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 11 other followers

A. Getting Started
There are a number of ways to set up a test environment on your own local computer.
Numerous applications and tutorials for a variety of operating systems are located in the
Setting up a development environment section of the handbook.
Reasons to run a local development server:
Developing locally allows you to work when not online.
Getting your local server running, even if it is with a simple installation like WAMP,
will help you start thinking in terms of server processes and databases. As you get
deeper into Drupal that knowledge will pay off.
Everything you put on the web is searched, archived and hangs around for a long
time. Do you want your inevitable learning mistakes displayed for the world to see on
Google?
This tutorial uses the example of building a site on a PC with Windows using the
DeveloperSide.net package.
This package has already integrated the following things:
Apache 2.2 HTTP Server
MySQL 5.0 Database
PHP 5.2 and Perl 5.8 Scripting Languages
GUI WAMP-stack Controller
Dynamic DNS Client
Tomcat Servlet/JSP Container
mod_aspdotnet ASP.NET Host Interface
OpenSSL Cryptography Toolkit
mod_security Web Application Firewall
phpMyAdmin MySQL Administration
Joomla
Drupal
WordPress
MediaWiki
phpBB
Do note that any package, like the DeveloperSide one, that includes Drupal for you may
not always have the latest secure version of Drupal. It is, therefore, recommended that you
check the version immediately and upgrade Drupal if needed when using these packages.
I followed their instructions, which built me a working system! For more instructions see
the Web.Developer page in the development environment section. I don’t remember if it
was automatic or not, but you will find it useful to have the “Web-Developer Controller”
icon on your desk top.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
4 of 39 25.10.2008 18:42
The only “fly in the ointment” was that when I went to the Drupal web site to start pulling
my modules and themes, there was a big announcement on the front page saying that a
new security release for Drupal 5 had been released and was highly recommended.
I downloaded the latest stable release. I then unzipped it (using WinZip).
Of course, that created a directory called “Drupal-5.1,” (the latest version at the time this
was written) but the other software I had installed was looking for a directory called
“Drupal.” Well, by getting Apache and its services shut down, I managed to rename the
two directories so that 5.1 was now called “Drupal.” It worked! I now had a running 5.1
system!
If you have not set up your site using a package that includes Drupal, it is still very easy to
install in a few minutes. You can find complete instructions in the handbook Getting
Started section under the version number you are installing. Here are the directions for
Drupal 5.
B. Basic Configuration
Whether you run one site or several, there are some basic things you should do right now.
Here’s what I do right off the bat; the advantage to doing it in the “root” database is that
when I make copies for my other sites this has already been done. I’d give you a link to
something on the Drupal site, but I never found anything like this.
Go to Administer>>User management>>Roles and create an “1. administrator” role.
Go to Administer>>User management>>Users and create a user entry for yourself. This allows you
to test the site by changing your role to meet your needs.
2.
Go to Administer>>User management>>Access control and allow the “administrator” role to do
everything.
3.
While you’re there, go ahead and set what the “authenticated users” (logged in) and
“anonymous user” (not logged in) can do, such as using your contact form. This is not
engraved in stone; you can change it any time you want.
4.
Go to the Administer>>Site configuration>>Site information page and, near the bottom, set the
“Default front page” to “node.” As long as you’re on this page, set basic defaults for
the other fields. I don’t know about everyone, but I don’t like, when I visit a site, being
called “Anonymous” so I change the designation to “Visitor.”
5.
If there are any modules (core or contributed) that you use on all sites, go ahead and
enable them now ((Administer>>Site building>>Modules). For example, you will probably use
“Page” on all sites, and maybe “Story.” I am finding more and more uses for “Book.”
6.
I do recommend turning on (enabling) the “Path” core module so you can use
“normal” names for your pages.
If you want to use the contact form to email anyone from the site, be sure to enable
the “Contact” module.
7. The same goes for themes.
There are a few things I recommend that you do in all your databases, so this is a good
time to do it:
Turn on “CLEAN URLS” to make your site more user friendly. Go to Administer>>Site
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
5 of 39 25.10.2008 18:42
configuration>>Clean URLs. At the bottom of the verbiage there is a link to run the “Clean
URLs Test.” If it passes, then the “Enable” radio button will un-dim. Click on that. (If
the URLs stop working for some reason here are instructions to unset clean URLs.)
In order for me to create any kind of content, I go to Administer>>Site configuration>>Input
formats and set “Full HTML” as the default until I get the site ready to go live. Then I
still allow administrators (like my other ID) to use that format. Do this now and you
will avoid a very common problem with building your site.
I don’t like having “Promoted to front page” as a default for content, so I go to
Administer>>Content management>>Content types and turn that off – in each format.
While you’re there, decide on your default comment mode. Go to Administer>>Content
management>>Comments>>Settings and set the comments to be entered on a “separate page” and
make sure that “Preview comment” is set to “Required.”
Now, let’s turn on the Contact form so your users can send you a message. Go to
Administer>>Site building>>Menus and locate the “Contact” item. Click on the “enable” link.
Remember that later on you will want to go to Administer>>Site building>>Contact form and
finish setting that up.
C. Creating Multiple Sites On a Local
Computer
Need another test site? Here’s how to do it the “easy” way. [Hint: if creating multiple sites
is desirable make a list of the desired sites before reading through these instructions
completely. Some steps can be done in bulk to save time.]
Why create extra sites? In addition to my having several sites running already, I had some
ideas in the back of my head, not the least of which being a site where I could document
everything I do (like this book). I also had some ideas for other sites that I might put up in
the future. So before you totally pooh-pooh the idea, give it a few minutes’ thought. And
you can always change your mind later; it just might be a bit messier then.
At the very least, I would create a “working” site other than my “root” site. This makes it
easier to start all over again if you get totally out of control later on.
This may look like a long process, but it’s deceiving because I spell it out in detail. It is
expanded and updated from the post “Running multiple sites on a local PC (localhost) from
a single codebase, using Windows.” For more details on the “official” stance on the sites
directories, read Setup of /sites directory for multi-site.
If you want to get deeper into creating multiple sites either locally or on your server, you
can search the forums at drupal.org with the term “multi-site”; there is also a group
devoted to this subject at http://groups.drupal.org/multisite. Within the Handbooks, there
is a good section: Multi-site installation and set-up.
Open phpMyAdmin (using “other” in Web-Developer Controller)
start bulk loop 1
On the left, select the Drupal51 database. This is the one that was created by the
package installation.
Click on “Operations”
Scroll down to “Copy Database to:”
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
6 of 39 25.10.2008 18:42
Enter the new database name.
Verify that the radio buttons are clicked for:
Structure and data
CREATE DATABASE before copying
Switch to copied database
Click on the Go button just below this area.
When the copy is complete, click on “SQL”.
In the “Run SQL query/queries on database” box, enter:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON
databasename.* TO ‘admin’@’localhost’ IDENTIFIED BY ‘superpw’;
FLUSH PRIVILEGES;
admin is what I call my administrative role (this is the “super-user” name);
superpw is the password for this user (I tend to use the same one for all my databases
to make it easy).
Hint: I created and saved this in c:/www/drupal/grant.txt so I could copy and paste.
Change databasename to the new database’s name.
end bulk loop 1
Close phpMyAdmin.
Go to the www/Drupal/sites directory.
start bulk loop 2
Copy one of the site folders (e.g. default) and name it for your new site.
Open the directory, then open the settings.php file in Notepad.
Change the $db_url and $base_url lines. The $db_url line should have the name of the
database you just created. The $base_url will be how you want to access the site.
Close the file.
If you are going to have site-specific modules or themes, go ahead and create
directories in this site to hold them (named “modules” and “themes”).
end bulk loop 2
Navigate to the /www/Apache22/conf folder.
Locate and open the “httpd.conf” file (Hint: I always make a copy of things I’m about
to change, just in case I mess up.)
I did notice that my version of Apache sets index.html ahead of index.php, so don’t have an
index.html in your directory.
Find the line that says “# Virtual hosts.” Remove the “#” from the next line. This
allows you to make all your other changes in a separate, and less dangerous file.
Save it.
Navigate to the /www/Apache22/conf/extra folder.
Open the httpd-vhosts.conf file.
At the bottom of the existing list, comment out (“#”) the examples.
start bulk loop 3
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
7 of 39 25.10.2008 18:42
At the bottom of the existing list, enter:
<VirtualHost *:80>
DocumentRoot /www/drupal/
ServerName databasename
</VirtualHost>
Change databasename to the new database’s name.
end bulk loop 3
Close the file.
Navigate to the /windows/system32/drivers/etc folder.
Open the Hosts file with Notepad. Hint: these two steps can be done by using “other”
in Web-Developer Controller.
start bulk loop 4
Add a line that says:
127.0.0.1 databasename
Change databasename to the new database’s name.
end bulk loop 4
Close the file.
Go back to Web-Developer Controller.
Click on Apache2 (top left).
Click the Stop Service button.
Wait for it to change to “stopped.”
Click the Start Service button
Wait for it to say “running.”
Go for it. You can now start the browser and enter http://databasename.
For more details on directories for multiple sites, see Setup of /sites directory for multi-site.
D. Error Pages
Occasionally, a user may do something that confuses Drupal, such as typing a wrong page
name or trying to access content they shouldn’t. These will generate 404 and 403 errors,
respectively.
A recent SEO newsletter, they mentioned the value of letting Drupal handle these errors:
Your unique 404 error page should look like a regular page of your site. It should
include your site’s header, footer and navigation bar so that the site visitor can
easily click on another area of your site. The content of this unique 404 error
page should contain text explaining that the page selected is no longer available
along with contact information so the site visitor has the option of emailing or
calling your company.
This was one of those “Duh” moments for me. How obvious it is that you should make it
easy for the user to get “back into” your site.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
8 of 39 25.10.2008 18:42
The same more or less goes for the “access denied” (403) error message. Let them know
they did a no-no and try to explain why.
Just go to “Create content” and select “Page.” I title them “Access Denied” and “Page Not
Found” but you can call them whatever makes sense to you and your users. When you
submit them, note the node ids. Then go to Administer >> Site Configuration >> Error Handling and
enter “node/nnn” in the appropriate boxes.
Page Not Found
Here’s the HTML for my 404 page:
<p>Sorry! The page you were looking for no longer exists. We redesigned our site and many of the pages have
changed.</p>
<p>&nbsp;</p>
<p>If you are unable to find something on our new site or have a question about our site or services feel free to
<a href=”/contact”>contact us</a>.</p>
<p>&nbsp;</p>
<p>–Webmistress</p>
Access Denied
Here’s the HTML for my 403 page:
<p>We’re sorry, but you must have permission to view the page you requested.</p>
<p>&nbsp;</p>
<p>If you are already a registered member of this site, please try <a href=”user”>logging in</a>.</p>
<p>&nbsp;</p>
<p>If you are not a member, you need to <a href=”/join_us”>join us</a>.</p>
<p>&nbsp;</p>
<p>If you have any questions about our site or group, please feel free to <a href=”/contact”>contact us</a>.</p>
<p>&nbsp;</p>
<p>–Webmistress</p>
Don’t worry that you haven’t created the “join_us” page yet. This is an advantage to having
URL Alias support (the Path module) enabled. Just add to your to-do list to create this page
when you get to the “Creating Content” step a few chapters later in this book.
E. Accessing Your Test Site(s)
Okay, great, now we have all that software installed. But how do we use it?
First, open the “Web-Developer Controller” that you put on the desk top. Look at the top
left. You want to see, and should, if Apache and MySQL are running. If they are, you’re just
about ready. If not, select Apache, then click on the “Start Service” button. Within a few
seconds it should change to “Running.” Now select “MySQL” and start it.
Fabulous, we have the software ready for us. Now let’s get us ready.
Fire up your favorite browser. In the Address field type in http://localhost/drupal/ to access
your “root” database. Since you’ve done everything right, you’re now into your Drupal
database.
Congratulations! Now the work begins.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
9 of 39 25.10.2008 18:42
F. Adding Modules and Themes
Let me first say that a newbie shouldn’t worry a lot about adding modules and themes at
first. Work on the basics of your site first, then worry about add-ons.
Themes are largely a matter of taste. For example, I have no idea why anyone would use a
“fixed width” theme, but lots of people do. One nice thing about themes are they are pretty
much independent of your content (later on you can look at the many submissions that are
dependent on content).
Contributed modules are ways to add or extend functionality of your site. The only module
I, personally, consider necessary is the Nodewords (a.k.a Meta Tags) module; in my
opinion, it should be promoted to “core” status. This one allows you to add the “content,”
“keywords,” and “robots” meta tags to your pages. This is useful if you’re interested in your
search engine rankings. You will also find that many contributed modules also require the
Views module; I go ahead and make that a standard one for my sites.
Now, if you experiment with different themes and modules, as I know you will, despite my
suggestions, you should also look at the Update Status (core in D6) and Site
Documentation modules to make sure you are current and to document and clean up the
mess your experimentation will make. Here are some suggestions on choosing the release:
Strong stomach?
Installation
Installing a module or theme is pretty much the same until you get to enabling them. Now
keep in mind that I use a Windows based PC (development) and Linux servers (on my live
sites).
Go to the Drupal site and click on the “Downloads” tab. Then select either “Modules”
or “Themes” depending on what you’re after.
1.
Locate the module 2. or theme you want.
Make sure there is a version for the version of Drupal that you are using. D5 modules
and themes will not work on D6.
3.
I always click on “Find out more” and read the stuff again. This gives you the chance
to see if there is support for your release of Drupal. You can also look at pending bugs
and feature requests – it might change your mind.
4.
5. Download the proper release. (I put them in a Drupal folder in “My Downloads.”)
Unzip the downloaded file (I use WinZip). It may tell you that there is only one file in
the zipped file; click “yes” or “OK.”
6.
Extract the code to to your /sites/sitename/modules or themes folder. If you are not running
multiple sites, this would be /sites/all/modules or themes.
7.
8. That’s it! Now you need to enable it.
For advanced users
If you have access to a Unix shell (e.g. SSH), the following series of commands will
download and extract the files directly to your server.
Before you start, use the pwd (print working directory) command to confirm that you are in
the correct directory (e.g. modules). If not, use the ls (list directory) and cd (change
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
10 of 39 25.10.2008 18:42
directory) commands to navigate to the correct directory.
Steps:
Step Download Archive:
wget http://copy_and_paste_archive_url/sitedoc-5.x-1.x-dev.tar.gz
1.
Step Uncompress Archive: tar zxvf sitedoc-2. 5.x-1.x-dev.tar.gz
3. Step Delete/Remove Archive: rm sitedoc-5.x-1.x-dev.tar.gz
Note: the module sitedoc-5.x-1.x-dev.tar.gz is taken here as example please check the current
version and or substitute with your preferred module.
Modules
Modules
You enable a module at Administer>>Site building>>Modules. The non-core modules are listed
farther down. With 5.x, they now show you some of the inter-module dependencies. I turn
them on and “Save configuration” in order of the dependencies. For example, “Views UI”
requires “Views”, so I turn on “Views” first, save the configuration, then turn on “Views
UI.” and save again.
Most modules introduce some kind of menu items. Those will generally appear
automatically when the modules is enabled. A few menu items will not show up until the
permissions are set (the next step). And even fewer require you to take action to add the
menu items, but the module will have instructions on how to do that.
Ah, now the real work begins. Go to Administer>>User management>>Access control to select who can
use the features of the new module.
If the module introduced new content types, go to Administer>>Content management>>Content types and
configure them. Don’t forget this may also affect your “Input formats” (Administer>>Site
configuration>>Input formats) and “Categories” (or taxonomy, Administer>>Content management>>Categories);
you’ll have to check those too.
Okay, now you can start using the new module.
This Site
My documentation site is a relatively “vanilla” implementation of Drupal.
Blog
Book
Comment
Contact
Help
Menu
Path
Codefilter – Provides tags for automatically escaping and
formatting large pieces of code.
Meta Tags (Nodewords) – Allows users to add meta tags, eg
keywords or description.
Site Documentation – Documents and cleans up your
configuration.
To get some idea of what modules are available, check these links: module handbook and
contributed modules handbook.
Themes
You enable a theme at Administer>>Site building>>Themes
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
11 of 39 25.10.2008 18:42
If it has never been enabled on this site, you will have to check the “enable” box and then
click the “Save configuration” button at the bottom.
To set up how the theme works, click on the “Configure” link (not the tab at the top).
Fill in the fields.
Save the configuration.
Don’t leave the page yet.
Logo and Favorite Icon
Now use that “Configure” tab
I prefer to do this part under the “Global Settings” but it can be done theme-by-theme if
you prefer.
The “Default Logo” is that little picture (usually) in the upper left corner of the page. For
example, on the “Bluemarine” theme, it’s the Drupal logo.
If you want to change it, here’s how:
First, find out what size it is because you’ll want your own logo to be about the same.
(If you are comfortable with HTML and CSS you can also edit the theme’s code to
accommodate your logo rather than resizing the image. How to edit theme code is not
covered in this beginner’s guide.)
1.
Bluemarine 48 55
Chameleon 49 57
Garland 64 73
Minelli 64 73
Pushbutton 144 63
Fancy 80 80
Under “Logo image settings” either type in the path to your logo, or upload it from
your PC.
2.
Note: Neither one of those options turns off the “Use default logo” check box. You
must select the correct check box yourself.
3.
The “Shortcut icon” (a.k.a. the favorite icon, or “favicon.ico”) is the same way. If you
want to change this, you must specifically say, “Hey, Drupal, I’m changing this.”
4.
Now you click the “Save configuration” button. If you did this in “Global settings” it affects
all themes (assuming they behave properly); if you did it for a single theme, then only that
theme is changed.
For a list of all available themes, check Themes.
HINT: Going to make a few (or a lot) of changes to a standard theme? Think about copying
it over to your /sites/sitename/themes/ folder and renaming it. Then you can do anything you
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
12 of 39 25.10.2008 18:42
want and still be able to undo it easily by recopying. If the changes ae a bit bigger, think
about contributing it back to the community (with your name, of course).
G. Creating Content
“Wow, I’ve done all this and I still don’t have any content on my site!” Well, let’s fix that.
First, let me explain that the page your visitor sees first upon entering your site is usually
called the “home” page. Drupal calls this the “front” page, much like a newspaper. This
page is special to Drupal. I know you’re in a hurry, but read about both “pages” and
“stories” before you decide which to use to create your front (home) page.
Content Types
Page
Drupal says, “If you want to add a static page, like a contact page or an about page, use a
page.” If you’re used to building web sites with HTML, this is what you’ve done in the past.
In general a “page” is going to stand on its own and will probably have a menu entry. You
may also later add it into a book. When I created my first two sites (based on former static
HTML sites, I made the front page a “page;” I have since changed to a “story.”
Story
Drupal says, “Stories are articles in their simplest form: they have a title, a teaser and a
body, but can be extended by other modules. The teaser is part of the body too. Stories
may be used as a personal blog or for news articles.”
Okay, you’ve seen the Drupal site and noticed that there are “pieces” all over the place.
Look at the front page; you’ll see several announcements with space between them – those
are “stories.”
I have now switched my sites to use stories on the front page. The “welcome” message is
one story. I have an announcement story node that any of my admins can edit. If you want
to have weather or cartoons, a story is a good idea. Another use is if you are on a net ring –
put the ring links into a story.
Book Page
Drupal says, “A book is a collaborative writing effort: users can collaborate writing the
pages of the book, positioning the pages in the right order, and reviewing or modifying
pages previously written. So when you have some information to share or when you read a
page of the book and you didn’t like it, or if you think a certain page could have been
written better, you can do something about it.”
Another way to use a book is to collect related information together. A book has its own
navigation, so it can also be used to de-clutter your menu.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
13 of 39 25.10.2008 18:42
Blog Entry
You probably already know what a blog is, but just in case: A blog is a diary, collection of
thoughts, or other time-ordered content. The Blog Entry content type is added by the blog
module. The blog module allows you to have a multi-user blog, meaning that every user can
have their own personal blog. This adds titles and breadcrumbs to indicate the blog
authors’ names. Generally if you only have a single blog for a site then it is best to use the
Story node for blog entries.
So have you decided what kind of content you want? No, okay, just start with a page; it’s
easy. As you go create your content, be thinking about the menu as well.
NOTE: If you want to set your front page (Administer >> Site configuration >> Site
information) as “node,” then you need to have at least one piece of content marked as
“promoted to front page.” If you don’t do this, you will keep getting that “Welcome to your
new Drupal site” message.
Another Handbook section you may find useful is Creating new content.
Adding Images to your text
There is a choice of facilities for adding images to text items, with pros and cons of each.
1. The Image module, and associated features. Makes each image into a Drupal node,
which ads a lot of capability.
· Image_Attach, which adds a separate image field to the target node, pointing at the
image node. Provides simple image upload, but little other control.
· Image_Assist which embeds the image in a text field. Provides visual image selector,
upload, and control over size and left/right float. Adds necessary HTML to text field.
· drupalimage plug-in to TinyMCE editor which makes Image Assist work with a TinyMCE
field, which displays the result as a WYSIWYG image (though not styled fully according to
your theme).
Also untested further features, including:
· Bulk upload facility
· Interface with the Drupal Gallery support module.
· Similar interface to the Acidfree support module.
2. The CCK ImageField. Very similar to Image Attach, but just uploads image into a
filestore file, and again contains little extra control over e.g. sizes or styles. It is almost
invariably used with Imagecache to give fine control for resizing.
3. IMCE( demo at http://ufku.com/drupal/imce/demo). Provides facilities to upload and
search for images on the server. Functionally similar to the Image_Assist/drupalimage
combination, but the integration with TinyMCE is neater for inserting images, and there is
more control over the attributes of the image once inserted. BUT the image filing and
select window does not look so nice – to the point of affecting usability, and there are bad
things on the Blogs about the associated gallery function.
4. Or go to FCK Editor. From the demo seems as good an editor as TinyMCE, and has its
own image upload and filing mechanism. But:
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
14 of 39 25.10.2008 18:42
· No automatic creation of thumbnails etc. (cf Drupal Image)
· Images are simple separate filestore files – may be a benefit depending on what one
wants?
I have oscillated quite a bit, but (at the moment) am going with the Image module:
· Install the Image module as normal.
· Do the stuff in http://mybesinformatik.com/tinymce-and-drupal5 to add the drupalimage
plugin to TinyMCE.
· Tune the settings in the TinyMCE Profile to show the features required.
· Create a Taxonomy to allow tagging of images for easier retrieval.
Front pages
After following the next few steps, you will be able to easily add / change your front page
anytime in the future.
1. Creating your front page
After logging in as Administrator, select
Create content > Page
from the left menubar, and create your own content that you would like to publish as a
front page. If you are done, hit „Submit” to see the results. Notice that the current URL
(the path to your newly created page) looks like this
http://www.example.com/?q=node/# (normal)
http://www.example.com/node/# (using clean URLs)
where # means a number. We will need that number, so write that down somewhere or just
try to remember that.
2. Front pages
Now you can either choose to
2.1. Set a single page as your front page or
2.2. Promote your page to the front page, this way adding it to the top of the front
page posts. (Only the first 5-10 lines will be published there (as a preview), you will
have to click on it to see the whole page).
2.3. Use the Front module to fully customize your front pages (theming, different user
roles…)
2.1. Setting your page as Front page
After creating your custom page, select
Administer > Site Configuration > Site Information
At the bottom of this page where it says „Default front page” you will have something like
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
15 of 39 25.10.2008 18:42
this
http://www.example.com/?q= (normal)
http://www.example.com/ (using clean URLs)
and an input field next to it. That is where you have to enter
node/#
where # is the node number that you previously wrote down. By pressing „Save
configuration” your front page automatically becomes the previously created page. You can
reset that any time you want, by entering only
node
into the input field. (That is the default value).
2.2. Promote your page as Front page
If you want to promote your page to the front page, you should go back to step 1. but now
don’t press “Submit”, or edit your newly created page (navigate to this address)
http://www.example.com/?q=node/#/edit (normal)
http://www.example.com/node/#/edit (using clean URLs)
where # is the node number.
Either way, at the bottom you will find a drop down menu called „Publishing options”,
there you will have to check the „Promoted to front page” checkbox and that’s it. Press
„Submit”.
2.3. Front pages with Front Module
If you really need more control over your front page, you can use the Front module to
Set a different theme 1. to your front page
2. Set different front pages depending on user roles (admin, anonymous, authenticated)
3. Insert custom php snippets into the front page
You can find the Front module at: http://drupal.org/project/front
After installing the Front module, select
Administer > Site configuration > Advanced front page settings
There the drop down menus are pretty self-explaining. If you click on any of the „Front
page for _user role_” you will find
Body: you can input text, html and even php snippets that you want to display
Select Type: you can set other user roles to have the same front page as this, have
default or custom themes be applied to it, etc.
Redirect to: you can set a location where users should be redirected to
If you are satisfied with your settings, press „Save configuration” and you are done.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
16 of 39 25.10.2008 18:42
G1. Creating a Page
Click on “Create content” in the menu, then select what kind.
The title and body are pretty self-explanatory. Below these are a number of collapsible
fields. “Input format” controls what you can put into the page; I’m assuming you are the
“super-user” (user/1), so give yourself the priviledge of “Full HTML.”
If you have Nodewords installed, the next section is “Meta Tags.” It’s pretty well
documented.
Use the log message to provide information that might be useful to other authors who may
edit your document later, or provide your rationale for making edits to your own or other
people’s content. The log message is not visible to users without the appropriate content
editing rights.
As logs are recorded on a per-revision basis, each time you revise your content and make a
log, the log message is stored with that particular revision of the article only. If you are
have editing rights over a page you can see a list of revisions (if you selected the option to
make a revision when you edited the document) and their associated log messages by
clicking on the revisions tab.
Hopefully, you already set your default “Comment settings” but the front page rarely
deserves comments, so you can disable them.
If you turned on the “Path” core module, you’ll have URL path settings next. You can enter
a “normal” name here rather than being required to use “node/2” when you refer to it later
on. Hint: if you are converting a site that was static pages, you might want to go ahead
and add “.htm” or “.html” to the name so that the search engines will continue to find the
page.
“Menu settings” is the next section. “Title” is what will show in the menu normally.
“Description” will show when the user hovers the cursor over the menu item. “Parent item”
allows you to create multi-level menus that collapse and expand. “Weight” allows you to set
a relative position within the menu; unfortunately, some Drupal core items are hard-coded
at 0.
Chances are you won’t need “Authoring information” unless you want to attribute the page
to someone else. The other use for this section is to control the page or story order when
they are based on the time and date it was created.
Finally, “Publishing options,” which you set defaults for earlier, right? You want the page
“Published” so it will show up. If this is your “Welcome” page, you’ll want it “Promoted to
front page.”
“Submit” it.
Congratulations, you now have some content on your site!
G2. Creating a Story
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
17 of 39 25.10.2008 18:42
Most of what goes for a page is also true for a story. You can largely consider the two types
to be interchangeable, and it is goodness to have at least two content types because
conflicts can arise in the way content types are used (for example, taxonomy “collisions”).
Stories have a “teaser” or opening statement intended to grab the reader’s attention. The
length of the teaser is set in one of two ways:
In Administer>>Content management>>Post settings. The default there is 600 characters. You can
change that.
By specifically identifying a break point with < !–break–> [without the space] in your
content (before the default limit).
Note: You may see some places that tell you to use <break> to set a teaser point. This
was originally changed in 5.0 and created a considerable controversy, so it was
backed out.
A story probably shouldn’t have a menu entry. If you use the general “convention” that a
“page” is for static or generated content that stands alone, and “story” is for collections of
related content (e.g. RSS feeds, newsletter articles, press releases, etc.), then a story is
usually going to be displayed with other stories, so which one would be the menu item?
Generally the menu for a set of stories will be a description of how they are selected for
display.
You may want to promote the story to the front page. For your “Welcome” message, you
probably also want to make it “Sticky at top of lists.” Unfortunately, there is no core
“weight” feature, so you have to play with the dates and times in the “Authoring” section to
control the order. (Or you can use the Weight module.)
What’s a Teaser?
This is from a post by zoon_unit on January 10, 2007.
A “teaser” is essentially a snippet of text designed to tell the user the content of a post
without reading the entire post. Since most writers have embraced the common
journalistic style of explaining the nature of an article in the first paragraph, teasers work
well for most articles.
Here’s what happens:
A node contains 1. an entire article.
Drupal’s “teaser” function, “node_teaser,” strips the first x number of characters from
the article and makes it available as content. The exact length is determined by the
value set in Drupal’s Administer » Content management >> Post settings.
2.
So, you list a bunch of articles on a page. You want the articles to display only a
snippet of text from the full article, so that you can fit a bunch of articles on a page
without requiring the user to page down through tons of text. If the user likes the
“teaser” content of the article, they will click on the article’s title and see the full
content of the article on its own page. In a sense, teasers function like summaries of
an article, except that the software decides where to cut off the text. If you want to
determine where a teaser article ends, you can insert the comment tag to instruct
Drupal exactly where to fashion the break between full text and teaser text.
3.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
18 of 39 25.10.2008 18:42
G3. Creating a Book Page
Generally, I only create one book page for each book. This is the first one, usually the
introduction. All other pages will be added as “Child pages” (to be accurate, child pages
will still have the “book page” content type set for them).
In addition to the things I said about pages, a book page has a “Parent.” For the first page,
this will be “<top-level>.” If you use “Add child page” the “Parent.” selection should be
already filled in with the book’s name. If you create another book page, you would need to
make sure you properly select which book or page the new one is to be made a child of.
The top page of the book probably deserves a menu entry. The rest do not, unless they are
really special. Remember, a book has its own navigation.
You are currently reading a “book.”
G4. Creating a Blog entry
Blog entries are a little different. Assuming you enabled the “Blog” module, you should see
a “My blog” entry in your navigation menu. When you click on that, there will be a “Post
new blog entry” link on that page.
If the blog is a diary, you probably want to use the date for the title.
If it’s a collection of thought, give it a meaningful title.
Type in the content of the entry.
Your blog will always show the most recent entries on the beginning page when visitors
view it.
H. Custom Blocks
Following is a simple example of custom block. For more information on blocks in general,
see the Blocks page of the handbook.
Adding A ‘Contact Information’ Block
A business or support group should always let people know how to contact them. One easy
thing is to include your mailing address on your pages. This is about the easiest kind of
block to start with.
Go to Administer>>Site building>>Blocks. It should already be sitting on your
default theme, but if not, select the right one.
1.
Click on the 2. “Add block” tab.
3. Fill in the “Description” and “Body.” Here’s a sample body:
Example Organization<br>
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
19 of 39 25.10.2008 18:42
123 Main St.<br>
Mytown, State Zip<br>
USA<br>
(123) 456-7890
4. Save the block.
5. Now you can “Configure” the block to add the block’s title and define it’s “Visibility”.
Follow the Configure link next to the block and enter “Contact Information” as the
Block’s title.
6.
Decide if you want to allow users to turn the block on or off, and, if so, which roles
should have that ability. You can leave this with no changes to allow everyone to see
it. Then choose which pages it will be shown on; Leave this empty to show the block
on all pages.
7.
8. Save the block.
Now you’re back on the block list. Find the block you just created in the list and
choose a “Region”. You can use the “Weight” parameter to set its position with in the
selected area; again, I like the address at the bottom, so I use a heavier weight.
9.
10. Click on the “Save blocks” button.
Adding a Last Updated Statement
It is fairly common practice, especially on a group site to let the visitors know when the
site was last updated. This example requires you, the webmaster or administrator
(sometimes called the “super user”) to maintain the block. There are ways to automate this,
but for right now, we’ll do this manually.
Follow the same process as for the ‘Contact Information’ block, giving this one a
slightly heavier weight to sink it to the bottom.
<em>Site Late Updated on Feb. 12, 2007</em>
For this block, lets set it to show on every page except the home (front) page. So
under “Page specific visibility settings,” I clicked on the “Show on every page except
the listed pages.” radio button, and entered <front> in the pages box.
Creating a Newest Posts Block
Creating a newest posts block is easy using Views. With slight modification you can use
this to list comments or list nodes by score if you have a rating module installed. The
information below is for version 5.X of Drupal. Things may be different in Drupal 6.X
Step 1 – Installing Views
Download install the Views Module. Follow the instruction that come with it.
Step 2 – Block Title
Determine what to call this block.
Step 3 – Number of Posts
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
20 of 39 25.10.2008 18:42
Determine how many posts you want in the block. You might also want to decide what
information you want to be displayed. For this tutorial we are going to display titles, but
you could display the teaser as well. The amount of information that is displayed could
affect your choice as to the number of posts to display.
Step 4 – Starting Views
Login to the admin page of your Drupal site and go to Site Building > Views.
Step 5 – Block Basic Information
Once you are on the Administer Views page, click on add. Fill in the basic information –
Name, Description, and Access Privileges. The name must be alphanumeric and you must
use underscores for spaces.
Step 6 – Basic Block Setting
Creating the block is very easy. Move down the page until you see word “Block” as a
hyperlink. Clicking on it will expand the block section.
Click on the check-box “Provide Block”. This means that Views will provide a block for you.
You will find it in the top of the block section.
Now we want to tell it how to display the output. You have several options but for this the
best is “list View”. Since we are just going to list the titles. If you wanted more information,
you could use the “Teaser List” to provide the name and description of the post. So, where
it says “List Type” you will select “List View”
Finally, you need to tell how many nodes you want in the list. Just fill in “Nodes per Block”
with the number that you want. If you are using a theme like “Denver”, you might want to
use 5 for the top regions. If you are placing in a side bat you could use 10 or more.
Depends on how fast your content changes.
Step 7 – Selecting Fields
After that is finished, you want to tell views what field you want to display. The next
section below “Block” is the “Fields” section. Click on “Fields” to open it. Then select the
field that you want. Then click on the “Add Field” button. For this example, we want to
select the title of the node. So you want to look for “Node : Title”. If you wish you can give
it a label like “Newest Posts” or “Latest News”.
Step 8 – Filtering
You may not want every thing showing in your latest posts. You can limit it. For that you
have to go down the page to “Filters”. Click on it to reveal the filtering options. This is
where you can select the content type(s) to show in the block. Where it says “Add Filer”
select “Node : Type” and then click on the “Add Filter” button. For the operator you want
to select “Is One Of”. Then you pick the content type from the “Value” drop down list.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
21 of 39 25.10.2008 18:42
Step 9 – Saving View
Once you are all done on this page, save your view.
Step 10 – Displaying the Block
Go to Site Building > Blocks. Here you will see all the blocks. Find your newly created one
and decide what region to place it. Depending on your theme, you may have a lot of
regions or very few few regions.
Once it is assigned to a region, set the weight. The larger the weight value, the farther
down the block will be on the page.
Once the weight is set, configure the block. This will allow you to decide who see the block
and on what pages it shows on. A good place to place a listing of newest posts is on the
front page. To do that, you want to find “Pages” and put in the text area. Then right above
select the “Show only on selected pages” option.
Once you are done making all your setting for this block, save this block.
Notes
You can use this method to show your content in other ways. You could show the highest
rated content or most recent comments.
You may want to have a special page for listing your 25 highest rated or 25 newest posts.
There are special modules that allow you to do this. You can use “Insert View” or
“Viewfield” to put views in pages.
Check out the modules for Views at http://drupal.org/project/Modules/category/89
I. Working with the Menu
Introduction
This will not be an exhaustive piece on the subject of menus. My main point will be to start
you on building your menu and giving you a flavor for how it works. A more complete guide
to menus can be found at Creating a menu structure.
As we all know the menu, or navigation system, can make or break a web site. It must be
easy to follow, often referred to as “intuitive.” It must be complete, yet compact.
There is a lot of content on the Drupal site on menus. Most newbies have trouble
understanding it all. I’ve been using Drupal for just over a month as I write this and I still
have a long way to go on completely understanding menus.
For beginners it can be very confusing to understand the difference between menus and
categories. The menu is a navigation system and categories is a system to order content
data. So menus is to arrive at content and categories to order it. Initially to understand
Drupal well, you have to see these as two separate things.
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
22 of 39 25.10.2008 18:42
With a menu you can point directly to a node, like a page or a story, but you can also point
to a term in a category, which would show you a summary list of stories or pages.
How To Menu
Drupal offers three primary ways, which may be combined, to provide your users with site
navigation.
Textual menu – this is the “standard” line-by-line type of menu, like what you see on
most sites, including mine. It can be enhanced in a few ways, such as using a CSS or
separate book navigation (as I have done here).
1.
Tabbed menu – becoming more popular because it’s a little more “gee-whiz” in its
presentation. It is debatable as to whether it is any more effective for your visitors. In
Drupal, it is divided into “Primary” (the tabs you always see) and “Secondary” (the
part that drops down, or slides out). Not all themes support secondary links.
2.
Books – Books are organized separately from menus, but have their own navigation,
which you can see on this site. See my section Creating a Book Page.
3.
Textual Menu
The textual navigation is the easiest to understand. As a matter of fact, I still don’t
understand how to make the “secondary” part of tabbed navigation work the way a lot of
people think it should (drop down).
You may see the terms “primary links” and “secondary links” in many posts. This is one
area where I find the Drupal documentation confusing (at best). While they sounded great,
and I am now using them, they may not be the best thing for someone just starting out.
Stick to the standard “Navigation” menu until you have a better feel; you can always go
back and change this later.
For the most part, the “standard” menu is best built as you create content, but may require
a little tweaking as you see how it lays out.
When you create a page, story, blog, or book page, one of the fields that you may (should)
fill in before submitting, is the menu entry (if the node is to have one). You have the “title”
(what is to appear in the menu as people see it) and a “description” (what they will see if
they hover the cursor over that entry).
I rarely worry about the “weight” until I see how it shows up in the menu. At that point,
you can either go back and edit the content you created or go to Administer >> Site building >>
Menus and edit it there.
Okay, that was the easy part. Now let’s say you want this particular content listed in the
menu as a
child of some other page. No problem! Let’s say you have a subject’s introductory page
already listed in the menu, for example “Family History.” The page you’re creating is
“1860-1899.” When you build the menu entry, you’ll notice a selection box labeled “Parent
Item.” Scroll down the list until you find “Family History.” Now when you submit this page,
it will be a child of “Family History,” making that item an expandable menu item. You just
created a hierarchical menu!
Tabbed Menu
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612
23 of 39 25.10.2008 18:42
In those themes that support this technique, the “Primary” seems to get built automatically
as you build the “Navigation” menu, unless you specify a different menu set. I have no idea
yet how to make drop down “secondary” links part work – I think it requires a separate
module. I do know how to make the secondary links appear in a block, if they exist. I like
the way that works, but it may not be for everyone.
Books
The book “menu” is built automatically for you. The only thing you have to worry about is
the order of the entries (hint: weight).
The only “complicated” part is turning on the book navigation block, which is done at
Administer >> Site building >> Blocks. All you really need to do is to tell Drupal which region to
place it in and its relative weight. You can get fancy, if you want, with your style sheets.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: