Hi, the general tpl naming convention for print/PDF templates looks like this:

  $variables['theme_hook_suggestions'][] = "print__node__{$type}";
  $variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
  $variables['theme_hook_suggestions'][] = "print__{$format}";
  $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}";
  $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}__{$nid}";

Above code is from print.module. I guess this naming convention is for node, not mentioning page from panel or views.
I've checked this post http://drupal.org/node/565856. This post didn't actually talk about the name of pdf template for panel page or views page.
Saying, I have a panel page "about-us", and the print url is "print/about-us". I checked page "print/about-us" source code. Apparently, this page uses the default print.tpl.php template to render this page. So, if I want to override this template, using a different template instead of the default one, what the name should be for that template?
Any help will be appreciated. Thank you.

Comments

jcnventura’s picture

Status: Active » Fixed

The template for non-nodes is print.tpl.php. There's no templating system available for non-content Drupal-generated pages.

smiletrl’s picture

Hi, jcnventura, thanks for yout replay.
I think the only option here is to use hook_menu_alter to change page callback for sepecific page.

jcnventura’s picture

It might be easier if you do some PHP inside print.tpl.php to include another template or similar.

smiletrl’s picture

Thanks, jcnventura
I guess I could do it like this:

  if($_GET['q'] == 'print/about-us') {
    include_once('print-about-us.tpl.php');
  }
  elseif($_GET['q'] == 'print/contact-us') {
    include_once('print-contact-us.tpl.php');
  }
  elseif($_GET['q'] == 'print/meet-us') {
    include_once('print-meet-us.tpl.php');
  }
  else {
    include_once('default_print.tpl.php');
  }

If this works, that will save a lot of time. Thanks again!

smiletrl’s picture

Hi, this works.
The only thing we need to change is ommit 'print' from url. So, this would be

  if($_GET['q'] == 'about-us') {
    include_once('print-about-us.tpl.php');
  }
  elseif($_GET['q'] == 'contact-us') {
    include_once('print-contact-us.tpl.php');
  }
  elseif($_GET['q'] == 'meet-us') {
    include_once('print-meet-us.tpl.php');
  }
  else {
    include_once('default_print.tpl.php');
  }

where 'default_print.tpl.php' represents the default print.tpl.php from print module. Hope this could help others who share the same problems with me.
And again, thanks jcnventura.

Status: Fixed » Closed (fixed)

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

heyddi’s picture

Issue summary: View changes

Thanks for #5, really helped me :)