0

Just realised all my pages are now displaying a back button with this code I added to node.tpl.php <FORM><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;"></FORM>

Is there a way to change the code to include only some node content types?

  • 1
    why dont u using block? add code to block, so can be control for specific pages. – monymirza Mar 12 '13 at 11:19
  • Be aware that history.go(-1); doesn't always work as expected. If your visitor arrived via an external link (eg. search result in Google) your back button will make them leave your site. Breadcrumbs are often a more reliable solution. – marcvangend Mar 12 '13 at 13:21
  • Thanks I will learn about how to use breadcrumbs, from the little I've read in this instance it would be of little use because the navigation is too basic. – cea Mar 12 '13 at 23:49
5

Duplicate your node.tpl.php file (in your theme's folder) and rename it to node--[content type].tpl.php. Use machine name of the content type, which can be found in Administer > Structure > Content Types Replace content type with name of your content type. (i.e for page content type, node--page.tpl.php)

Don't forget to flush all caches when you have placed the new code in this new template.

Drupal will now use this custom template file for this node type, and the node.tpl.php base template for other types.

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.