Pages

Wednesday, August 22, 2012

Top 5 Tips for Working with Drupal


#1  Don't use generic classes and IDs in your theme

This seems counterintuitive at first.  Naturally you want to name your toolbar "toolbar" and your content "content", but this will cause nothing but heartache down the road.
The trouble is Drupal and other 3rd party systems already have styles defined for these generic classes and IDs.  This will make your styling in Drupal more difficult, and if you use a third party shopping cart it will likely have styles defined for these very same CSS selectors.

#2  Use Drupal links where possible

When creating links from one entity to another try using the actual Drupal links rather than their URL alias.  For example, if you create a link to "/node/12" Drupal will automatically display this using node 12's URL alias.
The end result for the visitor is the same.  They will still see your pretty URLS.  Should you latter change the URL for node 12, your existing links will continue to work.
There is a module for CKeditor which will do this for you.  Have a look at CKEditor Link - A plugin to easily create links to Drupal internal paths

#3 Backup often

Before making any substantial changes it is wise to backup the database, the file system or both.  While nodes have "revisions" to undo our mistakes, blocks, menus, and other configuration items do not.  This is especially true when updating Drupal or it's modules.
Since so much of Drupal is stored in a database, it pays to have a convenient method for backing this up.  For this task I recommend Backup and Migrate.

#4 Configure cron

This is worth mentioning as it is so often overlooked.  Cron is used to keep your search index up to date, run scheduled backups, send newsletters, update your sitemap, and any number of other tasks added by modules.

#5 Consider the webmaster

When developing any system for use by others it's important to keep the user's skill set in mind.  Often the person tasked with updating a web site has little or no HTML skills, and very rarely is a skilled developer.
It is always our goal to develop a site that most anyone can edit and extend with only minimal training.  Our goal is to have all of the content and data entered directly into Drupal. This way it can be edited in the same manner.
To achieve this we need to be careful not to put content into our templates or stylesheets.  Instead consider creating more blocks and content types as needed

10 Top Drupal Sites


The Onion

TheOnion.com in Drupal

Lime.com

Drupal site Lime.com

Ubuntu.com

Ubuntu.com used to be Plone, but they switched to Drupal:
Ubuntu.com - from Plone to Drupal

Yahoo Research

Yahoo Research in Drupal

Mplay.com

Mplay - Sony-BMG using Drupal

The New York Observer

The New York Observer - Drupal

Fast Company

fast-company-com.png

Warner Bros Records

Warner Brothers Records in Drupal

Popular Science

drupal-popular-science-com.png

Team Sugar

Teamsugar.com is a great Drupal site, and it looks like they may still be running Drupal 4.7!
Drupal - Team Sugar sites

Drupal 7 update from removing welcome message


In version 7.x of Drupal, the unwelcome module is no longer needed. Just delete the Basic Page from the content tab as show below:
Deleting Welcome Message

Top ten tips for Drupal newbies


Looking back, if I’d known what I was getting into, I never would have started developing my new site in Drupal. But I got there in the end, and my mental health is frayed but still approximately intact.
Some of the terms I had never heard of when I started included CMS, CSS, PHP and MySQL. To pay it forward, I thought I’d share with you a few things that were SO not obvious to me, and which took me an unreasonably long time to figure out.
Bear in mind that I’m still totally technically incompetent, so do read any comments that appear below this post, as they’ll surely be pointing out all kinds of grotesque errors…
1. What the heck is this Drupal thing anyway? OK, so my best understanding of this is that it’s a little software package. It’s written in a language called PHP. It’s made up of core modules which you can download from http://drupal.org/project/drupal, and a bunch of optional (or “contributed”) modules, which you can surf athttp://drupal.org/project/modules. All of this then sits around in a little set of folders.
2. Where does my Drupal installation live? Well, if your first step has been to download Drupal to your computer, it won’t be able to work there. It likes to live on a server, not on your computer at home. In your future, when you’ve developed your new site a bit, you’ll want to put it on the internet, and your Drupal installation will sit on your server. That is, the server at your web hosting company. It will sit there in a little folder. That’s where it’s happiest. In the beginning though, if you’re going to build your site on your computer at home, you’ll need to download a pretend server environment, like Dev Desktop from Acquia,http://www.acquia.com/downloads. This will create the server-ish environment that will let you run Drupal on your computer.
3. Note that you don’t need to know anything about PHP to build a site in Drupal. When you search (preferably on Google) for a solution to your latest Drupal problem, a lot of the pages that come up will be providing snippets of PHP code. This is not the correct help information for you, the Drupal newbie. This is for technically competent people who are able to build their own modules and stuff like that. If you look at the other pages thrown up by your search, you will probably find an answer to your problem which involves working within the existing Drupal core and modules. That means, a solution you can implement using menus and tickboxes and whatnot, without needing to mess around with code.
4. Be careful where you put your optional modules and themes. Within the folders of your Drupal installation, there is a folder called ‘modules’ and one called ‘themes.’ These are NOT where you should put any contributed modules and themes that you add to your core installation. These folders are just for the core modules and themes. The folders you should use are a second set also called modules and themes, which sit within the ‘sites’ folder in your Drupal installation. (To make matters more confusing, if you use Dev Desktop it puts your whole Drupal installation into a folder called ‘sites.’ You need to drill down further a couple of layers to the other ‘sites’ folder. Sigh.) The reason all this matters is because you don’t want to mess around with the core Drupal installation (“Never Hack Core”). This is because the core will need updating from time to time (when security updates are issued), and you will have made life quite a bit more difficult for yourself if you have jumbled up the core and non-core stuff. You would be at risk of losing bits of your non-core stuff, that you worked hard to put in place.
5. The content of your site does not live in your Drupal installation. It lives in a MySQL database which is managed by your Drupal installation. This database will sit somewhere on your server, as determined by your web host. (As an aside, I never did figure out where Dev Desktop puts the database on your computer at home. It’s fully mysterious.) Anyhow, the exception to this is that the images within your site do live in your Drupal installation, they are in the sites folder somewhere (depending on your settings), with Drupal keeping records of them in the database. So, if and when you want to transfer your Drupal installation and your site from one place to another (like, from your computer at home to the server of your web host), you can copy/zip/etc the Drupal installation (including the image files) like any other set of folders. The database you can export either using the Drupal modulehttp://drupal.org/project/backup_migrate or an application which works with MySQL databases like http://www.phpmyadmin.net/home_page/index.php, installed on the same server as your database.
6. How to log into your site in maintenance mode. If you put your site into maintenance mode (using the configuration page of the admin section of your site), it will not be accessible to internet users who are not logged into the site. This is handy to keep it hidden while you’re still developing it. If you go ahead and log out of the site, however, it will not be accessible to you either. Ooops! The solution is to go towww.nameofyoursite.com/user/login. Then you can log back in. When I say ‘nameofyoursite’ I mean the actual name of your actual site.
7. Which modules to use? There are a lot of modules, lots of them doing similar or related things. You want to try not to have too many modules, because they each slow things down a little bit, and because you'll have to maintain them (by installing updates as they are issued). http://drupalmodules.com has reviews. To help you assess the health and life expectancy of a module, look, on the module's project page, to see how many people are using it (at the bottom of the page). Look at the top right to see how recently people have been committing to maintaining it. Look at the bottom right for links to related modules. Check if the module you want is available for the version of Drupal you are using. Versions of the module that end in things like .dev and .beta are still in development and may have bugs. By the way, to add a new module to your site, it is not enough to put the modules’ files in (the correct folder in) your Drupal installation. You also have to open your site, go to the modules page in the admin section, and enable the new module.
8. Which theme to use? http://themegarden.org/drupal6/ is a good place to browse through themes. You may find one that suits you, and is available for the version of Drupal you are using, without any tailoring. In which case, great! If you want to amend one though, it seems like it is often very hard work to start altering a contributed theme. You may be better of using one of the themes that are actually designed for you to tailor them, like http://drupal.org/project/zen or http://drupal.org/project/adaptivetheme. When you turn one of these themes on (by selecting them as default within the appearance page of the admin section of your site), your site will suddenly look terrible. All bald and ugly. This is because these themes are designed for you to add all your own styling. You do this by creating a subtheme to sit beneath this base theme, and then creating/editing the CSS of your new subtheme. You may be able to copy and paste some or all of the CSS from another contributed theme that you like, as a starting point. Check the intellectual property rights before copying. This site http://www.w3schools.com/cssref/default.asp is a key reference source for creating or editing CSS.
9. You can type content straight into a block. Now, maybe you’ll find this dead obvious, but I’d been working for several months with Drupal before I realised that, as well as creating blocks with Drupal, you can also click ‘add block’ on the blocks page, and just type whatever text you like into your new block.
10. How to link from one node to another. If you want to put a link into the body (the main text) of your node (or another field in the node), unless you’re using a WYSYWYG editor, you’ll need to type the link in HTML. If you were linking to a separate website, the HTML might look like this <a href= "http://www.amazon.com">click here to go to amazon</a>. You could do something similar for links within your website, but it would slow things down. It is more efficient to look at the URL of the page you are linking to, strip out the http and the www and the name of your site, and do something like <a href="blog">Blogs</a> or <a href="forum">Forum</a> or <a href="content/jessicas-article">Jessica’s article</a> or <a href="node/20">Jessica’s article</a> (where 20 is the nid). <a href="/">Home</a> will link to the front page of your site. <a href="node/add">Create page</a> will link to the add node page. To use an image as the link, do something like <a href="node/20"><IMG SRC="sites/default/files/SmallBizTribe-logo.gif"></a>. Depending on the address of the page you are linking FROM, you may need to add ../ or even ../../ at the start of the destination address to push the address back up a level, for example <a href="../user/jessica-kennedy">Click here</a>. Meanwhile note that you will need to have selected Full HTML or Filtered HTML as the text format for this text, or you’ll just see what you’ve typed, rather than a link.
11. How to see the NID of a node. If the node is in ‘edit’ mode, you can see the nid in the URL. (A node, in case you’re wondering, is a page like an article or a forum posting. You can design what fields it has and how they is displayed. Typically a node will consist of a heading, some body text, maybe an image, etc. Drupal assigns two URL addresses to each node, a human-friendly one made of words, and a nid, or node id.)
12. How to add hover text to a link. Within the HTML of your link, put TITLE=”Words you want to see in the hover”, for example <a href="../blog" TITLE="More blog posts" >more</a>.