开发者

Custom theming for content type in Drupal

I can apply a custom theme to a certain content type in Drupal by copying the node.tpl.php file and placing the name of my content type right after the "node" in the file name and appending an hyphen. Ok, the new name is: node-page_two_columns_images.tpl.php.

But that won't give me much flexibility if I am not able to edit the way each of the fields of my content type are rendered. If you get the node.tpl.php file, here is the line I am interested in:

<?php print $content ?>

I need to edit the way the elements in $content are rendered. Why? Basically because the title of the page needs to go between two of these elements... more or less like this:

<div id="field-1-of-my-content-type">[stuff1]</div>
<h1><?php print $title ?></h1>
<div id="field-2-of-my-content-type">[stuff2]</div>

Is there a template file I can create to replace the elements in this $content va开发者_运维技巧riable or do I need to write my own specific function?

Thank you!


check out the content template module.


Instead of using $content, you can print out all the elements yourself, as they are available in the node template. That way you can arrange the title and CCK they way you want to.

Update:
The easiest way to theme a node with CCK fields is to use $field_[field_name]_rendered, it has the themed version of the CCK field. CCK creates that variable to make theming the node easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜