I have created an override template for the poll content type called "page--type--poll.tpl.php" using a preprocess hook, but now I need to create extra effect on this template so that when people click on the title from the front page the node will show in a lightbox. I got the lightbox effect to work, but it still shows the whole node, How I can tell drupal that this content type has two templates and that the difference is which link they clicked from the view.


The way I've handled this is by adding a extra $_GET parameter to the end of the lightbox link url-s. For example if the url is http://www.example.com/somepage then you could turn it into http://www.example.com/somepage?lightbox=true. This can be done via javascript if it's troublesome modifying the view - might even be more suitable so that users with javascript turned off will get a better template. Then you can tell Drupal to use a different template for lightbox content this way:

function mytheme_preprocess_page(&$variables) {
  if (isset($_GET['lightbox']) && $_GET['lightbox'] == TRUE) {
    $variables['theme_hook_suggestions'][] = 'page__lightbox'; // page--lightbox.tpl.php

Lightbox show node, so you should theme only node "node--poll.tpl.php", instead of whole page "page--type--poll.tpl.php".

  • but poll type has a landing page And a lightbox preview, thats why I need the page--type--poll.tpl.php – saadlulu Feb 17 '12 at 1:26

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.