English 中文(简体)
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 variable 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.





相关问题
Drupal Multi-language: Simple strings not translated

I m adding additional languages to a Drupal site that I m building. Getting the translation of content working is fairly easy using the Internationalisation module. Yet, simple things such as date ...

Setting up a WYSIWYG editor for Drupal site users [closed]

Looking through the Drupal contrib modules, and after a few Google searches, it becomes evident that there are any number of choices and combos available to set up a WYSIWYG editor in Drupal. I m ...

Change size of user/password login box

I don t know how to change the size of the login username/password boxes on the drupal site that I m trying to build. I m stumbling through the theming, and don t know where to find the file that ...

How does Drupal provide an edit/review/publish model?

How does Drupal support a means to update and review a website before it is published? Does it only allow you to preview a page at a time before you publish it or is there a way to create a site ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

Has anyone checked out Drupal 7? [closed]

Has anyone checked out a copy of Drupal 7 yet? What do people think? I m pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure. Do ...

热门标签