5

Have changed everything else for the cart in the settings file but the page title doesnt work. Page title is 'Shopping cart' so would expect it to be basket as its set below however this is changing the title of 'basket' link (which is good) but not the page title. Suggestions please?

$conf['locale_custom_strings_en'][''] = array( 
  'Shopping cart' => 'Basket',
  'Shopping cart (@count items)' => 'Basket (@count items)', 
  'Shopping cart (1 item)' => 'Basket (@count item)',
  'Your shopping cart has been updated.' => 'Your shopping basket has been updated.',
  'Your shopping cart is empty.' => 'Your shopping basket is empty.',
  '%title removed from your cart.' => '%title removed from your shopping basket.',
  '%title could not be added to your cart.' => '%title could not be added to your shopping basket.',
  'Add to cart' => 'Add to Basket',
  'Update cart' => 'Update Basket',
  'View cart' => 'View basket',
  'Shopping cart contents' => 'Shopping basket contents'  
);
5

There are probably a dozen different places you could do this, personally I'd go for hook_page_alter() in a custom module:

function MYMODULE_page_alter(&$page) {
  // Make sure you're on the right page
  if ($_GET['q'] == 'cart') {
    drupal_set_title('New title');
  }
}

You would probably get away with doing the same thing in your theme's template.php file (maybe in hook_preprocess_page()) if you're not keen on writing a custom module just for this functionality.

The alternative to this is to install the String Overrides module. I've used this module in the past to override the title for exactly the same page (/cart) and it works great. It also means you can take your translation strings out of the settings.php file, which in my opinion isn't necessarily the best place to have them (even though it's absolutely a 'Drupal' way to solve the problem).

1
  • 2
    Great, thanks Clive, hook_page_alter() worked in the custom module. Just so others know hook_preprocess_page() in the theme template doesnt work. Apr 12 '12 at 10:57
3

Another flavor using hook_menu_alter

function mymodule_menu_alter(&$items) {
    $items['cart']['title'] = 'Order Confirmation';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.