Hi,

I can't get cck node replacements too work.

Is this already functioning?

Comments

davyvdb’s picture

Found it myself...

You have to give the node to token_replace...


function page_title_page_get_title() {
  static $title = NULL;

  if (is_null($title)) {
    // If frontpage, then use the frontpage pattern and set the title.
    if (drupal_is_front_page()) {
      $page_title_pattern = variable_get('page_title_front', '[site-name] | [site-slogan]');
      $title = token_replace($page_title_pattern);
    }
    //Otherwise this is a non-frontpage page title.
    else {
      //Get the current type for the page being displayed
      $type = page_title_get_type();
      
      //Get the pattern for this type
      $page_title_pattern = variable_get('page_title_type_' . $type, '');
      
      //If pattern is emtpy (either if the type is not overridable or simply not set) fallback to the default pattern
      if (empty($page_title_pattern)) {
        $page_title_pattern = variable_get('page_title_default', '[page-title] | [site-name]');
      }
      
      // Return the title
      $node = node_load(arg(1));
      $title = token_replace($page_title_pattern, 'node', $node);
    }
  }
  
  return $title;
}

nicholasthompson’s picture

I used to do this but I believe I stopped because it broke some things... like views I think.

I shall investigate. Thanks for pointing this out!

davyvdb’s picture

Even better is...

      // Return the title
      if(arg(0) == 'node') {
        $node = node_load(arg(1));
        $title = token_replace($page_title_pattern, 'node', $node);
      } else {
        $title = token_replace($page_title_pattern);
      }
niklp’s picture

This does nothing for me... :(

nicholasthompson’s picture

I believe this issue is fixed by the patch in this issue:
http://drupal.org/node/214994

Can this be tested?

nicholasthompson’s picture

Status: Active » Fixed

I've committed a fix for this which is included in Alpha5. I'm marking this as fixed because I tested Alpha5 with CCK fields in the title and they do appear. Please reopen if you cannot get Alph5 and CCK working together...

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.