Learning Drupal is the smartest thing you can do.

- Panic 2006

News from the front

takker for den! :D @perandre


1 day 15 hours ago

Trying to give something back to the wonderful Drupal community.

bilde
Morten Nicolay Nielsen - All Rights Reserved. Powered by Drupal, held together by Blueprint Css.

Count nodes by content type

The tutorial "Count all nodes" is a great tool if you need statistics displayed on you're site. If you want to specify by content type you can do it like this:

<?php
$mytype = array('you're content type name');
$in = implode("', '", $mytype);
$count = db_result(db_query("SELECT COUNT(DISTINCT(n.nid)) FROM {node} n WHERE n.type IN('$in') AND n.status=1"));
echo "$count";
?>

To enable this, activate the Php Filter from Drupal core modules and create a block with the php-input-filter selected. Works very well, and remember, you can theme this easily to make it look pretty :-)

Theming

Panel variants

This tutorial is about the Panels module, and how you can use the Node Template to create different layouts for you're content types. For the ad-site I made, I had 7 different content types. Different fields and different field groups created with CCK had to be displayed differently when users viewed an ad. Panels 3 was just released and it's the first time I use this module for a production site.

I recommend using CCK fieldgroups when creating custom content types. When doing this you can place the fieldgroup itself in panel pane and not fields, it could save you some time depending on how many fields you have created.

Panels

CCK and Imagecache

If you want to use images in you stories you may use an editor like Fckeditor or Tinymce. If you're running a newspaper site or a site where images is used frequently you should consider using CCK and Imagecache. To take advantage of this tutorial you should read the Imagecache tutorial, it's about how to configure and use the Imagecache features and the CCK tutorial.

This is basically the same as the CCK tutorial, creating a field and how it will be displayed when viewing a node.

Modules

How to use CCK

Content Construction Kit is one of the most downloaded modules at drupal.org. The module is so populare that it's functionality will be buildt into the next Drupal release. If you need extra functionality, a new content type or need to modify existing ones, this module is a must. It's a good trick to know what you want before you install it, there are several cck-addon's and you can be confused at times. Take it easy, start with a simple text field and when you feel comfortable, go further.

Modules

Add regions to a theme

At first it was a little confusing, but after reading about .info files and studying the garland theme I gave it a try. In my case I needed to print some content on my frontpage, there was not enough regions available so I had to create my own.

The theme's info file is the place to start. It is within you're theme folder and is called themename.info. Default regions is listed here and to create new ones use the same style as the default, just copy them and rename (add as many as you like).

When updating a theme info-file you have to visit the Site building theme section so that Drupal can check for updates, in some cases you might need to clear cache. To see if the new...

Theming

Node statistics and views

Have you seen the frontpage of virb.com? they have a stats-list on the page. My project is an "ad-site", free to use here in norway. If you want to create something similar to the stas-list on virb.com this is how you can do it. This tutorial is about how you can count nodes published within a certain catergory.

Views

Count all nodes

For a site that let users create advertisements I needed to display how many nodes that actually was published or available. Since I'm not a programmer I went into drupal support on irc and a helpful person handed me this code.

<?php
$result = db_query('SELECT COUNT(*) as nodes FROM node WHERE status = 1');
$arr = db_fetch_array($result);
print_r($arr['nodes']);
?>

To enable this, activate the Php Filter from Drupal core modules and create a block with the php-input-filter selected.

Imagecache

Instead of using a editor to display images I am using the Imagecache module. The module lets you set up presets for image processing. I created a newspaper site once, where one image had to be displayed in four different sizes. Headline story, thumbnail, archive and recent posts. Imagecache is perfect for this.

With a few steps you can create different sizes for images and tell content-types where and how images should be displayed. You definitely need some other modules when using imagecache.

CCK - http://drupal.org/project/cck
Image -...

Modules

Images in Drupal menus

This way is a bit more dynamic. It's using four images for different hover and active effects. When using this technique you can easily add or remover menu items without the need of editing or replacing images. It's a background effect and the example is the menu at this site. If you know photoshop or similar programs you can create various styles and better looking menus then the one at this site.

Theming

Image menu in Drupal

One of my biggest challenges when I started using Drupal was how to create a menu that used images. I created a support issue at drupal.org, either my english sux or maybe the solution was to obvious. This tutorial is using the same method as the apple menu. It uses one image and background-positioning. You can create very nice menus using this method, the only problem is if you want to remove or add a menu item, most likely you have to edit the menu-image.

Theming
Home