User login
theming
Theming a CCK Node
Submitted by peach on Tue, 01/22/2008 - 20:35.It's easy to create a custom node with CCK, but what if we want to change how the node looks by default? It's a step up from theming your submitted and your terms code, but it's not really that hard. The main difference between theming the CCK node and the regular node is that in node.tpl.php, we have several content sections within a node, so rather than just printing $content, we will print out parts of the content individually. I will use code from the wallpaper node type of this site for my examples.
Step 0, before we get to the phptemplate part of this tutorial, you have to think to yourself if you really need to theme a specific node programmatically. In many cases, you can style a node just fine with CSS only, so first imagine how you want to theme your node and determine if you really need to get into the templating engine.
Subsequently, we need to create a template file for our node type, make a copy of your themes node.tpl.php and rename it node-typename.tpl.php. In the case of my wallpaper node on this site that will be node-dwall.tpl.php.
Drupal Adsense Trick #2: adblocks between teasers
Submitted by peach on Fri, 01/04/2008 - 13:10.This article is the sequel to my first drupal adsense article. This time we're going to put adsense blocks in between teasers, on for example our frontpage. Same as last time, this does not require any modules, nor does it depend on adsense, it works with any phptemplate-based theme and with all sorts of ad code.
For starters, we're going to create a new block region. If there is not a template.php file in your theme folder, create one and open it up. See if there is a block regions function, if there is, add a new block to it: 'betwteasers' => t('between teasers')
If you didn't find a block region function copy this code into your template.php file (this code should be in between <?php and ?> tags):
function yourtheme_regions() {
return array(
'right' => t('right sidebar'),
'left' => t('left sidebar'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
'subnav' => t('subnav'),
'betwteasers' => t('between teasers'),
);
}
