By page title I mean <title>My Dynamic Page Title</title>. I would like to populate this with dynamic content from cck fields. Can I call the node variables on my page.tpl.php page? I tried using drupal_set_title on my node page, but it of course also changes my node title which I don't want. I have tried the page title module, but this doesn't solve my "dynamic" desire.
Thanks, and yes I'm a newbie!

Comments

gpk’s picture

In a word: yes!

gpk
----
www.alexoria.co.uk

dogboy72’s picture

Thanks for your help

trevorleenc’s picture

Then how? I'm searching for a solution to something similar right now.

gpk’s picture

Hmmmm looks like something got deleted from this thread.

Use drupal_set_title() to set the window title (this will also populate the $title in page.tpl.php, see http://api.drupal.org/api/function/drupal_set_title/5) ... if you are viewing a single node in page view then $node->title is available in page.tpl.php so you can use that or ($node->whatever) as your h1 or h2 heading ...

gpk
----
www.alexoria.co.uk

dogboy72’s picture

I have products that each have their own node. I want the page title to have content describing that unique product. So here's what I did.
Since we manufacture wedding gowns I set up a new content type called "Gown". I used cck to create fields that describe the gown (Fabric, Silhouette, Neckline etc.) Next I created a custom page template for this content type:" page-gown.tpl.php" In the head of that page I load and write the variables that describe that gown:

<title>
<?php
$item_nid = $node->field_gown_fabric[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_title = $item_node->title;
print $item_title;
?>, 
<?php
$item_nid = $node->field_gown_neckline[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_title = $item_node->title;
print $item_title;
?>,
<?php
$item_nid = $node->field_gown_silhouette[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_title = $item_node->title;
print $item_title;
?> - 
<?php print $head_title; ?>
</title>

Notice I left the normal head title so that the final result is, for example:
French Lace, V-Neck, A-Line - Alexandra | Designer Wedding Dresses | My Company Name

The first three items the cck fields I have loaded. The rest is what drupal creates: "Alexandra" is the node title and the name of the gown. The rest is the name of my website.

I know there are other ways to do this, but I found this to be the best for my situation. Good luck!