Hi Team,

I'm sorry to ask what I think is a really simple question, but I've pored over the forums, Google and the Drupal 6 Theming guide, and I can't find a page that explains how to do this.

Latest version of Drupal 6, LAMP on Debian Etch.

I've enabled the built-in view called "frontpage" and pointed my homepage to this. Working fine. I've added two fields via CCK to the Story node: source and summary. All text fields.

I built a very simple theme with a page.tpl.php and node.tpl.php. Working fine.

But what I want to adjust is the parts of the Story that display on the homepage. Right now it shows:
title
published date
category
summary
content/body of the story
source

The problem is, in the node.tpl.php file, $content contains the summary, content and source together, but I want to be able to lay them out and output them separately.

One goal is to only show the title, date and summary on the homepage, with a read more link. And on the details for a Story, I want to further adjust the fields. Like node.tpl.php, my page.tpl.php file lumps my Story fields into $content, and I can't control it.

I think I'm missing something really obvious about theming, perhaps.

Help!

Thanks,
jpe

Comments

yelvington’s picture

The $content variable that is offered to page.tpl.php is prepared by node.tpl.php.

By default, a "river of news" view runs node.tpl.php repeatedly. The length of the $node->body may be trimmed by the system, depending on how you've configured it.

If that's not what you want, you can place conditional code in node.tpl.php. Check for $page == 0; if true, you're looking at a view and not a simple (single node) page.

You can restrict your template to a single content type by naming it appropriately: node-TYPENAME.tpl.php, page-TYPENAME.tpl.php, et cetera.

With Drupal 6, the variables available in each template context are documented at api.drupal.org and not in the theme developer guide, as they were for Drupal 5.

jemond’s picture

Thanks, I appreciate the reply.

However, I'm wondering how to break into the $content part, which also appears in my node.tpl.php file.

It's that $content that contains the source, body and summary bundled together.

I'll look at api.drupal.org.

kuldip zala’s picture

hi,

comment $content variable in node.tpl.php.
check what you want by printing $node like print_r($node) and according to that print whatever
you want.

jemond’s picture

Thanks, everyone.

The print_r($node) helped. I also read the READMe file about CCK, and discovered it makes variables of the extended fields available to me in themes when used.

I figured this out.