tags:

views:

46

answers:

2

Hi there

In my page.tpl.php I have an ‘if’ statement that checks to see what node is being used and then add a class to the ‘container’ element relative to the node i.e.

<div id="container" class="clear-block <?php if ($node->type == 'card'): ?>card-node-type<?php endif ?>">

But I would also like to add a class to the ‘container’ element in the page.tpl.php if I’m adding a new node ‘/node/add/card’ but I don’t know how to test for it as it is not a node type. How would I go around testing for this?

Many thanks

A: 

I've sorted it. I duplicated the page.tpl.php and renamed it to page-node-add-card.tpl.php (card being the node type I'm adding) and then added the class to the element in that file.

Nick Lowman
This is ok, but doesn't scale very well as you can quickly get lots of nearly identical templates
Jeremy French
Thanks Jeremy. I'll use the preprocess_page function as you and googletorp suggested is the correct way.
Nick Lowman
A: 

A better solution would be to check the args in the preprocess_page function and then add a variable you can print. You could make that dynamic to work for any node type.

googletorp
Deleted my post, I think you must have got in there first with the same answer.
Jeremy French
Thanks googletorp. There seems to be many ways to achieve the same thing with Drupal and as I'm a newbie I find it a little confusing.
Nick Lowman

related questions