Pages

Thursday, September 6, 2012

Running Drupal on Windows using WAMP

I haven't actively administered Drupal on Windows, and in fact had never installed WAMP before creatingDrupal Essential Training. The course includes a nine-minute "Installing WAMP and Drupal on Windows" video, but here are some additional tips I've discovered since the course was released.
  • Increase PHP's memory settings or you might have problems backing up and restoring your Drupal site. You'll see the issue if you go to the MySQL-controlling phpMyAdmin screen (probably athttp://localhost/phpMyAdmin) and click "Import": The maximum file size allowed is 2,048K. That's only 2MB, and the databases for most Drupal sites are much larger than that. (The example site for Drupal Essential Training gets as big as 5MB.) To change this limit:
    1. Click the WAMP icon in your system tray.
    2. Select "PHP". In the side menu, select "php.ini" to open a file containing PHP's configuration options.
    3. Search for the line, "upload_max_filesize = 2M".
    4. Change it to "upload_max_filesize = 32M" (or whatever you like).
    5. Save the file and restart WAMP. (Better yet, restart your computer entirely to be sure. I'm frankly not sure whether it makes a difference.)
    6. Now go back to that "Import" screen in phpMyAdmin: You should notice that the limit has changed. (Thanks to L.H. for pointing this out.)
  • L.H. writes: "In Windows Vista, the WAMP icon disappears from the system tray after x time (not sure about the duration protocols). To make the WAMP icon re-appear (so that you can access localhost, phpmyadmin, php.ini, etc.), you have to activate the "start WAMP server" icon (from start menu, desktop or wherever); then the system tray icon reappears. Pain in the chicken, but that's Vista."

Updating Drupal 7 to the Latest Version


Updating a Drupal site is vital for security.
In this tutorial we're going to show you how to update your Drupal 7 site from one minor version to another. That means from 7.0 to 7.2 or 7.2 to 7.4. and so on.
Unfortunately moving between major versions such as from 5 to 6 or from 6 to 7 is a much bigger topic and too large for a single tutorial.
Before you start, please remember one thing: backup, backup, backup, backup, backup, backup, backup, backup your site!

Step 1: Check for Available Updates

tutuploadsmedia_1309637650420.png
To get started with updating your Drupal site, click on "Configuration" and then "Available updates".
tutuploadsmedia_1309637693049.png
This page will show you an updates you need to make. They will be marked in red as in the image above. If there are updates, it is worth putting your site in maintenance mode at this point to avoid any problems for your users as you update.

Step 2: Download the Update Files

tutuploadsmedia_1309637713390.png
Drupal will show you a link to download the files for the new update.

Step 3: Upload the Update Files

tutuploadsmedia_1309638026715.png
Unzip the files that you've just downloaded.
IMPORTANT: Delete the /sites/ folder from these unzipped files. Do not upload the /sites/ folder as this will overwrite any custom work that you have done. Make sure that you leave the exisiting /sites/ folder intact on the server.
Then open up your FTP program or file manager and navigate to your existing Drupal site files. Simply upload the new files over the top of the existing ones.
tutuploadsmedia_1309638514359.png
Once the upload is complete, you can refresh your "Available updates" page and hopefully it will now be marked in green rather than red.

Step 4: Run the Update Manager

Drupal Updates
Click on "Modules" and then click on "Always run the update script each time a module is updated".
tutuploadsmedia_1309639399700.png
Click "Continue".
tutuploadsmedia_1309639419498.png
Click "Apply pending updates".
tutuploadsmedia_1309639442264.png
You should now see a page saying the update has been successful with no errors.
Click on the "Administration pages" link and go "Configuration" then "Maintenance mode" to put the site back online.

Wednesday, September 5, 2012

Basic Drupal site configuration


Here I will point out some things that should be done by yourself after you have installed Drupal. It's a basic Drupal site configuration - some things that I always do when I create new Drupal website.
I assume you have installed Drupal on your web server. Installation is very easy, it's a matter of "point and click". Just make sure you create your database before that. More info on Drupal installation can be found in install.txt file that comes with Drupal installation.
So, you've just installed Drupal on your web-server (or your localhost), and now you ask yourself: "Hmmmm..... Now what?". Of course, it depends on the nature of your future website what you want to do with it, but before all that there's some basic Drupal site configuration that I always do, and I suggest you do it as well.
You are presented with a nice blue theme and a welcome message "Welcome to your new Drupal website!" and some additional info on setting up your Drupal website. I suggest you read that text and then do the following:
1. Go on and create your first account by clicking "create the first account." link. That first account that you create will be the admin account for your drupal website! It will have a user id of 1. You can name it "admin" or whatever you like.
2. After that you are back to frontpage of your installation. Go to your admin section, and click on "Modules". On modules listing page, mark checkboxes for the following modules: Contact, Path, Search and Statistics. Click "Save configuration". This will install some additional core modules that are not enabled by default, but I always use them.
3. Enable Clean URLs by visiting admin -> Site configuration -> Clean URLs (you need to have mod_rewrite Apache module enabled for this to work).
4. Go to admin section. If you see a message at the top that says "One or more problems were detected with your Drupal installation. Check the status report for more information.", don't worry about it, we'll fix that in a minute. Click "Site information" and fill in all those fields for your Drupal website. I think they are all pretty much self-explanatory :-)
5. Next, click "File system" in admin section. You will hopefully get a message that "Files" directory was created. Click "Save configuration".
6. Now we need to setup Cron for out Drupal installation. In case you didn't know, cron is a unix process that works in a background all the time and it can execute certain commands for you at any time you tell it to do so. Drupal NEEDS cron job to be set up in order to function properly. So, login to your VPS (or dedicated server) and type following command:

crontab -e
This opens up your cron edit screen. Add the following line to it:

0 9 * * * wget -q http://www.your-domain.com/cron.php
This tells your cron to execute cron.php script at exactly 9am every day. You should be fine with it, although you can choose whatever time of the day you want.
(in case you don't have shell access, and you are on shared hosting, you should have some kind of setting up a cron. I know that in Cpanel you can set up a cronjob very easy, through graphical user interface. If you cannot do that, I suggest you contact you hoisting provider for assistance about setting up your cronjob for Drupal).
7. Ctrl+X and 'Y' and Enter. You should be out of your cron settings program. You can check if you successfully added cronjob by executing
crontab -l
8. Now go back to your browser, to your admin page of Drupal installation. You can run cron manually now, and then you shouldn't do it anymore, since we've just set up a cronjob for Drupal. Now you shouldn’t receive any error messages at the top of the window in admin section.
9. Go to front page of your Drupal website. You are going to create your first piece of content in Drupal.
Create content - > Story
Create it! Be creative ;) Write something just for fun, as we have a little bit more to configure. After you click Submit, your "story will be created. Congratulations, you've just created your first piece of content (node) in Drupal.
10. Go to your webroot directory where your Drupal installation is. Open up your .htaccess file and add following lines to it:

RewriteCond %{HTTP_HOST} ^your-domain.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
or, if you have 'www' part in your domain name, add this instead:

RewriteCond %{HTTP_HOST} ^(www.)?your-domain\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
Save ".htaccess" file.
What this does is that it gets rid of a trailing slash at the end of your Drupal URLs. So, if you type URL with a slash at the end, it will automatically get rid of it. This is extremely important for search engines like Google and your website ranking, that's why we do this.
You should now have a basic Drupal website up and running with minimal number of modules running.
I suggest you now play around your Drupal website, explore the admin section a little bit more, just to see that it's nothing really difficult there. Any questions or suggestions, I'd be happy to read them.

How to make a photo gallery with thumbnails in Drupal


Here we will create a simple photo gallery for Drupal CMS that will have thumbnails listed in a table with 3 columns. First of all, please have a look at how our final result will look like:
Would you like to have something like that on your website? Read on…
The way I made this photo gallery is kind of a hack, or workaround. It might not be the right way of doing it, but IT WORKS, which is the most important thing.
1. Enable following modules: Image, CCK, Views, CCK Nodereference, Path, Pathauto
2. Go to Image settings in admin section and set the options just like on the following picture and save configuration:
Capture1.jpg
3. Create a new content type “Album” with just “title” field enabled. We will just need to enter title for our albums.
4. Go to Pathauto setup and set following options:
For “Pattern for all Album paths:” put “gallery/[title]”
For “Pattern for all Image paths:” put “gallery/[title]”
Save configuration.
5. Create a new view and name it “album_list”, check “Provide Page View”. For URL you can put anything you want. For view type select “Table view”
  • In fields section, add field “Node: title”
  • In filters section add filter “Node: type” and select operator “is one of “ and for value select “Album”.
  • Add filter “Node: published”, for operator select “Equals”, for value select “Yes”
  • Click Save. Now we have our view that we will make a reference to.
  • Go to admin -> content types -> Image
  • Click “Add field” tab
  • Give it a name “album”, and for Node reference select “Select List”
  • On the next screen, for label put “Album”, check “Required”
  • Click on link “Advanced - Nodes that can be referenced (View)”, and for View select “album_list” from dropdown list.
  • Save field settings
6. Now, go on and create a new album”… Create content -> Album. Name it whatever you want, for example “My photos”.
7. Extract the archive attached to this article. There are 2 files “node-album.tpl.php” and “node-image.tpl.php”. Make sure you upload them to your themes/your_theme directory.
8. Now we will add some images to your album. Go to Create content -> Image. Click “Choose” to choose your image. For Album, select the name of your photo album that you have already created ("My photos" or whatever).
9. When you create your image, it will take you to something like
http://www.iwant2visit.net/gallery/amsterdam-1 . The last part of URL is the name of your image.
10. Keep on adding images to your photo album. Don’t forget, every time you upload an image you have to select name of the album that a new image will belong to.
Now you can have as many photo albums as you want and as many images as you want.
You can also experiement and make those pathauto settings to suit your own needs.