简体   繁体   中英

Drupal 7: Is it possible to print a cck field in the html.tpl file?

I am looking to use a cck field as the page title. The $pagetitle variable is found in the html.tpl.php file. But it does not look as if I can access any nodes.

Is there a way to do this?

If you would like a module to do this, check out the Page Title module.

This module gives you granular control over the page title. You can specify patterns for how the title should be structured and, on content creation pages, specify the page title separately to the content's title.

I think there may be a bug with getting the CCK fields as available tokens but I believe there's a patch available for it.

You can identify the relevant cck field and print its value instead of the default page title. Try:

drupal_set_message('<pre>' . print_r($node, TRUE) . '</pre>');

... in your content type template file. This will output all the contents of $node. Beware, it will be messy, and it may take you a while to find what you're looking for!

Out of curiosity, why are doing this?

You can do this by using hook_preprocess_page() function and change the page title. See http://api.drupal.org/api/drupal/modules--system--theme.api.php/function/hook_preprocess_HOOK/7#comment-24423

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM