Monday, May 31, 2010

CCK - Compound Fields - Image + Rich Text Caption + Taxonomy...

Here is a great article, outlining how to create your very own compound fields for use in CCK. The article EVEN (!!!) supplies you with two concrete implementations of modules, as added bonus...
- Image + Rich Text Caption + Taxonomy
- Modified User-page fields

You may download these two modules from the bottom of the same page, as linked to above...

Taxonomy, Vocabularies, Terms, and their uses

When using Taxonomy you are quickly faced with the daunting possibility to "view Taxonomies as you need to"... (in no particular order):
  • Classical categorization; As stated in the Drupal docs, where a single taxonomy corresponds to the animal kingdom classification into groups such as "Mammal", "Fish", "Bird" etc.
  • Used in code-decisions; Use taxonomy and terms to indicated relations between content - For example when presenting a page-view as a collation of nodes (left/right, three-column, multirow... whatever collation). Here you may need a taxonomy named "Page-Position" with the terms ("Left", "Center", "Right" etc.), in order to create a varied but manageable website for your administrators/editors and users.
  • Multiple node-representations at once; Used to view a node in several different contexts on your website. You may for example choose to view a piece of news in a teaser-block on the frontpage, while simultaneously presenting it on a news-archive page in full view-mode (teaser+body+etc.). This is also useful in the case where you selectively want to use nodes in RSS-feeds - Create a taxonomy for RSS, and you're set!
Do note that taxonomies are all capable of being sub-ordinate to other taxonomies, and as such they offer the ability to group content in sub-ordinate relations.

Sunday, May 30, 2010

SimpleMenu and Devel Themer Conflict...

These two modules, which separately are awesome tools, conflict with each other...

I haven't found documentation of the specific conflict, or the reason why they conflict -But they do.

Activating the Devel Themer module, immediately disables the display of the SimpleMenu, so re-enabling the display of the SimpleMenu is a matter of visiting the relative URL "?q=admin/build/modules" - locating Devel Themer module, and disabling it.

Please contribute with comments, and especially solutions found for this :0)

Themes per content-type, and not only per node ID

This addresses the issue of ONLY having the possibility of theming nodes per node-ID, e.g:
"page-node-101.tpl-php"

In order to overcome this, and provide theming for each content-type (Defaults are of course "page", "story" in Drupal 6) that you may have created using CCK, you should look to modifying the code of the "theme_preprocess_page" function in your main "template.php"-file of your chosen theme.

Code to include in theme_preprocess_page
Here is the code to include...

// Add per content type pages
if (isset($vars['node'])) {
// Add template naming suggestion. It should alway use hyphens.
// If node type is "custom_news", it will pickup "page-custom-news.tpl.php".
if($vars['node']) $prefixName="page-node-";
else $prefixName="page-";
$vars['template_files'][] = $prefixName. str_replace('_', '-', $vars['node']->type);
}

And, as you will see, it gives you access to using two new template-names for your content-type:
- For views etc. node-listings: page-CONTENTTYPE.tpl.php
- For node-details views: page-node-CONTENTTYPE.tpl.php

Monday, May 24, 2010

Pretty URL's - Automatically

Pretty URL's in Drupal 6 are easily introduced at ANY TIME in your development cycle, using the Pathauto Module.

There is however ONE tiny fly in this ointment - In order to enable and use Pathauto, then you will have to introduce the Drupal Rewrite Rules into your web-hosts ".htaccess"-file, or directly into the Apache Directory Rewrite Rules for your website installation. ".htaccess"-files are the most commonly available option, on shared hosting anyway, and you then will just need to download the Drupal installer (if you don't already have this on-disk), and copy the very same ".htaccess"-file to the aforementioned location on your web-hosting.

NB! The Mac OS X Finder and Windows File Explorer (and their likes) may not show you the .htaccess-file, as it is a hidden file (prefixed with ".").
In these cases you will need to view your Drupal-downloaded installation (unzipped), directly in your FTP-application, and make sure that you are viewing all files, even the invisible or hidden ones.

The very last setting...
You need to make one very last setting in your Drupal installation; Visit the page at "/admin/settings/clean-urls" (being logged in as the admin-user), and make sure to enable Clean URLs!

HEEELP!!! Drupal WSOD problem... Why and How to recover

Remember the times when you have seen Bill Gates present a Windows feature to the world, and it all suddenly ends in the BSOD (Blue Screen Of Death)? This kind of problem probably gets a couple of MS-engineers fired ASAP.

Drupal has an equivalent to BSOD - The White Screen Of Death (WSOD) Read on to avoid "getting the boot" from your boss or customer for your Drupal website suddenly going white, and not showing any HTML or other code on inspection!

WSOD - Causes
WSOD in Drupal is most likely to bug you when:
  • You've installed (uploaded and activated!) one or several Modules that have bugs in them, or that they together act erroneously (module madness)
  • You've done something terribly wrong in one of the template/theme files
The first case is the most common, also as you will have guessed that the latter case is easily overcome by simply reverting your own code back to functioning state.

Solution to WSOD - Module madness
Drupal keeps a continuous status of which modules you have installed and enabled for your Drupal installation. These informations are collected together in the database of your Drupal installation. So, using your favorite database-editor (e.g. PhpMyadmin for MySQL), you should take the time to locate the table named "_system" (e.g. "drup_system"). In here, you will observe (upon inspection) that it has two data-columns of special significance; "name" and "status". "name" indicates, as you might've guessed - the Module Name, while the status is enabled/disabled (1/0) for each of these modules.
You will therefore need to disable any of the more recent modules that you've installed, and you should be rid of WSOD once more.
Disabling modules is accomplished by - You guessed it - using that same database-editor (PhpMyadmin) and setting the "status" of the suspected Modules to the value of "0" (ZERO).

Saturday, May 22, 2010

Developer modules

Just like you will need the essential modules, as the previous post outlines - then you, as the developer and designer of a Drupal website, will also benefit greatly from these...
  1. Devel Module+Devel Themer - Visualize content data, which template (theme) files that apply to a certain page or content-view, and use it to modify your pages and content!
  2. SimpleMenu* - Provide a general menu, always displayed at the top of your website - No need to reserve a block-position for this menu - it does it all!
  3. Zen-theme - A fasttrack to theming as you can literally "point-n-click" to create your own theme, and THEN specialize this theme to your liking
* SimpleMenu is great, but it has a conflict with the Devel Themer module (specifically the Themer module!), so use it with care, and when using for the admin-user you can switch Devel Themer on and off in your Modules Control Panel on your website.

Developer documentation and examples...

The general Drupal API can be found at api.drupal.org

In addition to this, you will also benefit from some select free screencasts - These display real-world usage of Drupal and Modules to provide certain custom page and content views. I can personally recommend these two...
  • Drupal Videos
  • Drupal School
Both of the above are accessible through iTunes and the iTunes Store...

Additionally, you might also like to have a copy of one or all of the Drupal Cheat Sheets lying around - It tells you all about the default variables, such as the login-status of your visiting user, and such essentials...

Totally necessary modules...

The Modules that you will need for the typical Drupal 6 Installation... All modules below are oriented towards content and editing of this content - See other post for Developer modules.

All work in well-tested Drupal 6.x-installation, so go ahead - go wild - Install ONE, install ALL
  1. Everyday editing... WYSIWYG
  2. Better, richer content on your page, and the content fields and types you crave... CCK
  3. Control the display of your content; blogs, listings, detailed views, with or without pager, meeting certain criteria... Views 2
  4. File, image and media handling - A collection
  5. Create your own forms - replace the limited built in Drupal Contact Module... Webform