Tuesday, August 24, 2010

DrupalConCPH day 2 underway

Wolfgang Ziegler is presenting the Rules module, and is getting started...

Rules are reactions to events. Events, as we all know, are the basic function of calling a Drupal URL.

Rules 2- Drupal 7 only is the order of the day at this session.

Rules 2 retrieves all content from node metadata, taxonomy can also be metadata. A possible client to Rules2 could be e.g. Services Module.

Rules 2 supports arguments through a Data Selector, and through direct arguments from tokens, data selection and data processors. Data processing could be date-manipulated input, or e.g. Data being summed through arithmetic.

Looping over listed content is a primitive, and need not be handled through php loops handcoded. Lists also feature insertion and removal operations; list_remove, list_add etc.

Reuse and saved rules are copyable and configurable for each entity/copyable of the first implementation.


- Posted using BlogPress from my iPhone

Location:Center Boulevard,Copenhagen,Denmark

Day 1 - DrupalCON CPH - Drupal, Joomla, WordPress, Typo3...

Point of departure
Comparing Drupal to Joomla, WordPress and Typo3 had the focus on this day one...
WordPress and Typo3 were thoroughly showcased by their "official representatives" - professionals dedicated to the two platforms/systems.  Joomla and Drupal was showcased by a German guy*, who also has authored books on both - at developer level for both systems.

Conclusions
  • A casual webuser, fed-up with the limitations of Facebook, MySpace and other hosted "blogger-solutions", are quite well served by WordPress
  • WordPress can be made to implement large sites, although is is NOT recommended!
  • Joomla is a bit of a legacy CMS system, quite capable, but marred by too many workflows that could well be improved, but are VERY integral to Joomla, so probably won't be.  Joomla is ONLY CMS not to currently include image-processing - Scaling, thumbnailing and soforth!
  • Drupal is great for websites, of pretty much any size, but the installation-process is tedious/overcoming for most newbies.  Drupalgardens.com may well serve as good starting point for WordPress-converts that want a free hosted Drupal-website.
    Drupal has, as a competing CMS, many things to learn in simplifications from WordPress!!! This is very clear!
  • Typo3 is by far the most advanced system of the four, but as seen from a non Typo3-tech's aspect, the system is just too daunting, also in everyday use for administrators.  Typo3 also has a very ambitious upgrade-path, and no particular support is given to assist the vital extension-developers in keeping up with "the curve", other than backwards-compatibility features. 
 
*: Will insert real name, when I re-read it...

Day 1 - DrupalCON CPH - Lessons/tips...

The following are the most important Drupal-related modules that were mentioned/debated at Day One of the Drupal Con CPH 2010:

The Modules
- Panels (Project-Panels)
- Display Suite (Project-DS)
- Data (Project-Data)
- Composite Layout for nodes (Project-Composite)

The Starter themes
- Zen
- BluePrint (Works with the BluePrint CSS library)
- Foundation  (comment was that it was in many ways FAR superior to Zen) 

Tuesday, July 27, 2010

Meets us at DrupalCon CPH 2010 (august 23'rd-27'th)

Morning.dk is now prioritizing Drupal very highly, as it has proven a great tool for delivering on-time and powerful solutions to our web-customers.  A part of this prioritization is attending DrupalCon CPH 2010, where we have high hopes of learning and networking with other Drupalists... Meet us there, and we'll talk :)

Highlights from the conference are the Keynote by the creator of Drupal - Dries Buytaert, as well as PHP-centric talks by several high-profile PHP professionals, as well as leader from the webdeveloping-community.  Clear-left and Ethan Marcotte will be talking of the future of HTML and HTML5.

Thursday, July 1, 2010

Drupal + nginx + fastcgi = smokin' hot website!

Drupal CMS is a bit demanding, as my previous posting re. APC Cache speedup pointed out. Apache Webserver is yet another beast of a system, and uses massive system processing power and RAM to run properly, especially in scaling to many concurrent requests. Nginx is a very high-performance server, and perfectly capable of smokin' Apache when running a Drupal site. This is accomplished through use of PHP in CGI/FastCGI mode.

Linux and Mac OS X servers can enjoy the fruits of the above setup, quite easily. Linux variants have their package managers, such as apt-get, yum and soforth. Mac OS X has the awesome MacPorts to accomplish the very same... an example for the setup is given at the link below, for Mac OS X. The situation for other Linux' is pretty much the same for installation and setup!

http://www.sussdorff.de/node/52

If you wish to run both Apache for some services and nginx for performance, then make sure to have them respond to requests at two different connection ports - typically 80 and 8080.

Tuesday, June 29, 2010

Checking whether a user has a specific role...

Drupal 6 makes it easy to check whether or not a user has a specific Access Privilege.  It is indeed used in most modules, as it is essential and yields much power and flexibility in use.

What Drupal 6 does however NOT make trivial, is to check whether or not a user has specific role ( a named role, e.g. "administrator", "authenticated", "member" - whatever roles you may use).
How-to
<?php  global $user;

 
// Check to see if $user has the administrator role.
 
if (in_array('administrator', array_values($user->roles))) {
   
// Do something.
 
}?>

Here we use the default full array that each user has as an attribute - the collected roles of the user!  Note that this array is keyed, and the role names (not unique!) are thus kept in the values of the keyed array!
Why is this useful?
Well, let's suppose that you have a list of nodes (a blog-style for example), and these nodes in the listing are authored by different users - different users with different roles indeed!  Using the technique above, will enable you to theme the blog-entries of each user-role, making it easier to visually tell them apart on-page for the reader of the blog.

Thursday, June 17, 2010

Accelerate drupal performance

Update: There are several modules available to Drupal 6 for caching pages, thus enhancing load-performance of your Drupal website.  I've personally tried the CacheRouter below, and have found this excellent article outlining an alternative - Boost & DB Maintenance.

Dedicated hosting setup
I just installed APC - the PHP opcode cache engine - on our server, and configured it as described in

APC Drupal Performance tuning

APC enabling & optimization makes Drupal websites SCREAM!

Shared hosting setup
If you are running your Drupal website on shared hosting, and don't have the option if APC ( as it is a server-wide installation, and not single-site!) then you might want to check out the Boost/DB Maintenance modules, or the one below...

CacheRouter Module
Update: I've tried this module on a website featuring AJAX loading of node content (through Views 2 Module), and experiencing rather high load-times with this combination.  Maybe Views 2 Cache needs to be enabled for the same content, maybe not.  I will test this later on - And please - if you test, then comment here... Thanks!

Tuesday, June 8, 2010

Page example module - Modules and menu routes

I was specifically searching for examples of how to create modules that present their content when called
through specific URL's in a Drupal CMS website. I came upon this example, and it looks quite simple and useable...

Module menu router example



Monday, June 7, 2010

Theming the "not-so-apparent" parts of Drupal content

An excerpt from the above-linked article/resource:
"You can create theme hooks for modules you did not write
When I wanted to theme the comments form the first thing I did was looking at comment.module. There I found a call like this:

drupal_get_form('comment_form', $edit, $title) 


Ok, I had a comment_form function that I could theme according to Drupal Form API, then I started looking for theme_comment_form but there was none.
How to override a theme hook that does not exist? Just as you do with your own modules, you just need to know the code involved and, this is important, you can include a hook_theme function in your template.php file. This is what I did for Woodpig:

function woodpig_theme() {
return array(
'comment_form' => array(
'arguments' => array('form' => array()),
),
);


The function starts with the theme name and the theme hook takes the form argument because it's a that's what drupal_get_form requires. Then I can write my own woodpig_comment_form($form) function."

Sunday, June 6, 2010

Nodes - Hooking into them, loading and saving with new overridden values

Check out this code-centric article on using hook_nodeapi in Drupal 6.  There are good code-examples and the section "Caveats" is especially worthwhile.

Friday, June 4, 2010

Drupal - How does it work...And how do I make it work for me?

Jeff Eaton presents Drupal to the developer.  He outlines the process of making a web-request, using index.php-controller as the stepping-stone, and how to hook into the Drupal-system.  "Hooking" is Drupals way of modifying functionality, and hooks are primarily implemented inside Modules.

Jeff does an amazing job of keeping it simple to understand, and reveals the processes that power Drupal enough to get you more than started coding your own Drupal Modules.

Wednesday, June 2, 2010

Node: Body outputs entire full node, instead of Body field

The problem is not, as the linked article here suggests, limited to Views representations of Node-body content.  The problem exists in any Node or Page template that is rendered to your website.

The problem arises from the fact that templating BOTH loads a Node, and then runs the "node-alter" routine on it - affecting the Node Body field specifically, to also include contents of CCK fields in that Node.

The problem-code
The problem arises when using this variable-call in a page-template (*.tpl.php) file:
print $node->body;
The solution-code
The solution is to replace the code above with this code instead:
print $node->content['body']['#value'];

Tuesday, June 1, 2010

Fast Install Drupal... DRUSH

DRUpal SHell (Drush) is without a doubt the fastest way of installing Drupal and other modules - the ones you ALWAYS use, the ones that you use for every Drupal installation...

Love thy terminal!
Drush is however a pure terminal (CLI) tool, and as such, you must (!!!) invoke and use it from the terminal... The most useful commands are:
  • "drush -h" - Get Drush help, see all of the things you can do through Drush!
  • "drush dl" - DownLoad (dl) Drupal in it's newest stable version
  • "drush dl [module] [module] [module]... [module]" - DownLoad the modules that you CRAVE!  This corresponds to downloading them from the Drupal Project's Website, and then FTP'ing them to the correct "/sites/all/modules" sub-directory of your Drupal installation
  • "drush en ...[module] [module] [module]... [module]" - Enable the modules that you just downloaded.  This corresponds to Enabling the modules through the Drupal Module Manager on your Drupal website
Install!
Installation of Drush is apparent from its project-page, but here is the specific procedure for Mac OS X - Also for those not quite comfortable with the Mac OS X Terminal Application.

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