Hi,
I've used page title before to great effect (imho this should be in core!)
I'm trying to build a new site using the superb 'tapestry' theme from roopletheme.com. The code on the template.php file is a little more confusing for me than other files I've seen. I'm no php expert, but I can find my way round to a very basic degree
The full template.php looks like this:
***********************************************************************************************
<?php
// $Id: template.php 11 2008-02-21 13:24:51Z bill $
// www.roopletheme.com
if (is_null(theme_get_setting('tapestry_style'))) {
global $theme_key;
// Save default theme settings
$defaults = array(
'tapestry_style' => 'gerberdaisy',
'tapestry_usefixedwidth' => 1,
'tapestry_suckerfishmenus' => 0,
'tapestry_suckerfishalign' => 'right',
'tapestry_fixedwidth' => '850',
'tapestry_fontfamily' => 0,
'tapestry_customfont' => '',
'tapestry_uselocalcontent' => '0',
'tapestry_localcontentfile' => '',
'tapestry_breadcrumb' => 0,
'tapestry_themelogo' => 0,
'tapestry_useicons' => 0,
'tapestry_ie6icons' => 1,
'tapestry_leftsidebarwidth' => '210',
'tapestry_rightsidebarwidth' => '210',
'tapestry_sidebarmode' => 'center',
'tapestry_outsidebar' => 'left',
'tapestry_outsidebarwidth' => '180',
'tapestry_iepngfix' => 0,
);
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge(theme_get_settings($theme_key), $defaults)
);
// Force refresh of Drupal internals
theme_get_setting('', TRUE);
}
function tapestry_regions() {
return array(
'leaderboard' => t('leaderboard'),
'suckerfish' => t('suckerfish menu'),
'sidebar_left' => t('left sidebar'),
'sidebar_right' => t('right sidebar'),
'sidebar_outside' => t('outside sidebar'),
'content_top_left' => t('content top left'),
'content_top_right' => t('content top right'),
'content_bottom_left' => t('content bottom left'),
'content_bottom_right' => t('content bottom right'),
'header_left' => t('header left'),
'header_center' => t('header center'),
'header_right' => t('header right'),
'banner' => t('banner'),
'user1' => t('user1'),
'user2' => t('user2'),
'user3' => t('user3'),
'user4' => t('user4'),
'user5' => t('user5'),
'user6' => t('user6'),
'user7' => t('user7'),
'user8' => t('user8'),
'user9' => t('user9'),
'user10' => t('user10'),
'user11' => t('user11'),
'user12' => t('user12'),
'user13' => t('user13'),
'user14' => t('user14'),
'user15' => t('user15'),
'footer_left' => t('footer left'),
'footer_center' => t('footer center'),
'footer_right' => t('footer right')
);
}
function get_tapestry_style() {
$style = theme_get_setting('tapestry_style');
if (!$style)
{
$style = 'gerberdaisy';
}
if (isset($_COOKIE["tapestrystyle"])) {
$style = $_COOKIE["tapestrystyle"];
}
return $style;
}
drupal_add_css(drupal_get_path('theme', 'tapestry') . '/css/' . get_tapestry_style() . '.css', 'theme');
drupal_add_css(drupal_get_path('theme', 'tapestry') . '/css/suckerfish.css', 'theme');
if (theme_get_setting('tapestry_iepngfix')) {
drupal_add_js(drupal_get_path('theme', 'tapestry') . '/js/jquery.pngFix.js', 'theme');
}
if (theme_get_setting('tapestry_themelogo')) {
function _phptemplate_variables($hook, $variables = array()) {
$styled_logo = '/images/' . get_tapestry_style() . '/logo.png';
$variables['logo'] = base_path() . drupal_get_path('theme', 'tapestry') . $styled_logo;
return $variables;
}
}
if (theme_get_setting('tapestry_uselocalcontent')) {
$local_content = drupal_get_path('theme', 'tapestry') . '/' . theme_get_setting('tapestry_localcontentfile');
if (file_exists($local_content)) {
drupal_add_css($local_content, 'theme');
}
}
function tapestry_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$styled_breadcrumb = '/images/' . get_tapestry_style() . '/bullet-breadcrumb.png';
$output = '
';
return $output;
}
}
function tapestry_block($block) {
if (module_exists('blocktheme')) {
if ( $custom_theme = blocktheme_get_theme($block) ) {
return _phptemplate_callback($custom_theme,array('block' => $block));
}
}
return phptemplate_block($block);
}
function phptemplate_menu_links($links) {
if (!count($links)) {
return '';
}
$level_tmp = explode('-', key($links));
$level = $level_tmp[0];
$output = "
- \n";
foreach ($links as $index => $link) {
$output .= '
$css_id = 'item-' . strtolower(str_replace(' ', '_', strip_tags($link['title'])));
$output .= ' class="' . $css_id . '"';
if (stristr($index, 'active')) {
$output .= ' class="active"';
}
$output .= ">". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."
\n";
}
$output .= '
';
return $output;
}
***************************************************************************************************
I've changed part of the template.php to the file to the below, but no joy!
if (theme_get_setting('tapestry_themelogo')) {
function _phptemplate_variables($hook, $variables = array()) {
// Dave added the below lines to try to get the page title mod to work
if ($hook == 'page') {
if (module_exists('page_title')) {
$variables['head_title'] = page_title_page_get_title();
}
}
// End of the lines added by Dave
$styled_logo = '/images/' . get_tapestry_style() . '/logo.png';
$variables['logo'] = base_path() . drupal_get_path('theme', 'tapestry') . $styled_logo;
return $variables;
}
}
Any help would be much appreciated!
Biggy
Comments
Comment #1
nicholasthompsonThats odd - your changes should have worked... Although I dont like it when people define functions inside if statments - it looks like the _phptemplate_variables function is only defined if you have a logo!
Try changing it from:
to
Comment #2
Biggynuff commentedCan't thank you enough Nicholas . . . works a charm!
As you mentioned, I was a bit concerned about the way I'd nested the if statements. Your way is much better. Sometimes, when you've been slogging over these things for a few hours, even the simplest things seem impossible!
once again, thank you
Comment #3
nicholasthompsonNo problems at all! I know what you mean about slogging over code. I often do code and then look at it again the next day and think "What on EARTH was I doing!?"
Anywho - glad its working for you! :-)
Comment #4
sasso1214 commentedHi guys,
I am having a similiar problem trying to update my .php code to get this module to work for my website. There is no "page" hook in my function _phptemplate_variables code, so I do not know where to add the code as directed in the readme. I don't know how to code in .php, but I have been trying for over an hour by looking at code to find a place to add this - I have not been having luck as I keep getting an error whenever I change the code.
Here is the code in the relevant part of template.php for this time (Danger):
/**
* Intercept template variables
*
* @param $hook
* The name of the theme function being executed
* @param $vars
* A sequential array of variables passed to the theme function.
*/
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
// Send a new variable, $has_terms, to see wether the current node has any terms
case 'node':
if(count(taxonomy_node_get_terms($vars['node']->nid)))
$vars['has_terms'] = TRUE;
else
$vars['has_terms'] = FALSE;
}
return $vars;
}
Thanks in advance for your help!
Comment #5
nicholasthompsonchange the function to:
Comment #6
wayland76 commentedHmm. Is there any chance that some of this could be
1. Generalised
2. Put in a separate file distributed with page_title
That would mean that it would be possible to just add an include, rather than all this other stuff :).
Comment #7
wayland76 commentedAllow me to retract that previous suggestion in favour of:
http://drupal.org/node/254799
Comment #8
nicholasthompsonI'll look into the features on http://drupal.org/node/223430 however those only apply to Drupal 6. Drupal 5 does not have these and the ONLY way in D5 to modify the page variables is from the theme.
Marking this as fixed as sasso1214 hasn't replied for nearly a month so I assume its solved.
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #10
spidersilk commentedJust a quick note to say thanks for this thread - the code you supplied to the original poster for use with Tapestry also works with RoopleTheme's Beale Street theme, with a few minor variations, and thus saved me from having to post a support issue of my own. :-)