It seems to me that in my theme at least the only class a node has is "node". There's no identification of what taxonomy it is (if any), what node type it is, or whether its a teaser preview or full text.

So these are the 3 classes I'd like added to nodes in the html of my theme:

  1. Node type
  2. Taxonomy categories the node belongs to
  3. Identification of whether the node is a preview/teaser or full-text

Is there a way to add this to my smarty theme in node.tpl without having to hack the node module or smarty.engine? Maybe a smarty plugin/function could make this happen for me?

I just want the most flexible, themeable website I can put together. Having classes allows me to use flexinode which is much more flexible than making custom nodes myself. Obviously I could create my own node and change the theme of how it's styled there but I'd rather not.

Thanks for your help as always,

Jay

Comments

styro’s picture

But if you want the most flexible theming, you'd want (IMO) to be using PHPTemplate themes. They also have the advantage of more docs and far more people being able to answer your questions about them.

eg:

"Node type"
Specialising in templates:
http://drupal.org/node/17565
http://drupal.org/node/23828
or for directly using, I think $node->type might work in your node.tpl.php template.

"Taxonomy categories the node belongs to"
http://drupal.org/node/11816 ($terms, $taxonomy and the $node object)
http://drupal.org/node/53089 (an example of using those variables)

"Identification of whether the node is a preview/teaser or full-text"
http://drupal.org/node/11816 (the $page variable)
http://drupal.org/node/53464

--
Anton
New to Drupal? Please read this
Also: Forum posting tips

drupalninja99’s picture

I grab $node->type to get the type and have an if $page eq 0 for the teaser identification. I don't know how to just get a list of terms without the html. I just want the names.

drupalninja99’s picture

Ya I got it to work yesterday using a smarty function and that api function using the $node->nid as the parameter.

One problem: the $node->type will show flexinode-1 for flexinode instead of the type name--how do I get the actual type name in 4.6?

benthere’s picture

You can use node_invoke() to get the real type name.

http://drupal.org/node/54059

Just need to convert that to smarty syntax and register the function for Smarty.

-- Ben // profilefx.com

benthere’s picture

EDIT: oops, somehow I totally missed the replies above. Well, at least I got a good mental exercise out of it.

1. {$node->type}

2. {$terms}

phptemplate info here in that 'foreach' loop.

3.

{if $page}<p>this is a teaser</p>{else}<p>this is a full node</p>{/if}

-- Ben // profilefx.com