2

I need to show a video in a light box on a site and am having difficulty. I thought I would create a normal page with the proper code but when I go to load the video the screen grays out then goes and loads the page but gets stuck as if it cannot do it. I also tried just creating an html file and loading it directly but it couldn't read it or failed or something. I am using fancy box and html 5 if that matters. How would I do this? If you need more info please let me know Thanks for any help guys

Edit: I have tried the solution below which is what i need it just isn't quite working yet. the url of the node is: http://fourcemag.com/homme/video and http://www.fourcemag.com/homme/video-0/video so the last part of the url is video

This is the code:

function fource_preprocess_page(&$vars) {
  $path = $_GET['q'];
  $path = drupal_get_path_alias($path, $path_language = '');
  $patharray = explode('/', $path);

  if ($patharray[2] == 'video') {
    $vars['template_files'][] = 'page--video';
  }
}

This is the error:

enter image description here

  • page--video.tpl.php

not sure what is wrong here. Please help Same error as before

4
  • The error you are getting is because it can not find the url arg "video-0", are you using the sef url? Try with "node/#/video-0"
    – WestieUK
    Mar 30 '12 at 7:12
  • I am using clean urls for seo so I cannot go back to the default urls. I tried eactly what you suggest but it still isn't working for the url: fourcemag.com/homme/video Based on what you suggest it should be working. What is wrong here. Mar 30 '12 at 17:25
  • Drupal will use 2 forms of URL, one which will be in the format of "/node/nodenumber" and the other will be the human readable search engine friendly url "category/article-name". Try the Drupal one and it should work. "fourcemag.com/node/46/video" just replace 46 with the actual number of the node
    – WestieUK
    Mar 31 '12 at 8:12
  • Is there anyway to do this without switching back to the default drupal urls...? My client is adamant about SEO friendly urls. There must be a way to do this. Mar 31 '12 at 21:48
2

You will likely want to define a custom page.tpl.php for use in the lightbox so it doesnt conflict with your normal site pages where you would like sidebar content etc.

Think of having 2 differently themed versions of the same page, your traditional page and a cut down version which is only the node content area.

To do this, add a theme_preprocess_page() so it creates a unique url argument to trigger the content only display via its own tpl.php:

function YOURTHEME_preprocess_page(&$vars) {
  // Get the path (eg node/#) and split it into an array ([node][#][video])
  $path = $_GET['q'];
  $path = drupal_get_path_alias($path, $path_language = '');
  $patharray = explode('/', $path);

  // If the last part of the path is "frame" use the page-content.tpl.php
  if ($patharray[2] == 'video') {
    $vars['template_files'][] = 'page--video';
  }
}

Then copy your exiting page.tpl.php into a page--video.tpl.php and trim out all the content you dont wish to see in your lightbox.

EDIT: (include details on using the video only page) In your iframe load your node page with "video" appended to the drupal url. For example "node/135/video" so it using the page--video.tpl.php

I have been using this solution to embed content from our nodes into another application and it works well. :)

9
  • Can you clarify what I should be filling in here? I underdstand YOURTTHEME but the rest not sure about. I need only over ride the tpl for the video node and any other video nodes in the future... Mar 29 '12 at 16:00
  • I'm getting an error on this line: if ($patharray[2] == 'resolve') { Mar 29 '12 at 16:22
  • I think you will have to do the page.tpl.php if you would like to use an iframe with no logo, menu, sidebar footer etc. My mistake on the error I left that in from my implementation. Updated my answer.
    – WestieUK
    Mar 29 '12 at 17:35
  • You can redefine "frame" and "page-content", frame is what would be used in the URL. While page-content is the template suggestion
    – WestieUK
    Mar 29 '12 at 17:40
  • Still not working for me... Same error. the url is fourcemag.com/homme/launch-video so I am using launch-video in place of frame. I am also using page-content as the suggestion. so page-content.tpl.php... should it be page--content.tpl.php...? Mar 29 '12 at 23:14
1

I need also in a site to display a page as a pop up in a shadow box,I used a colorbox module because it give me option to open iframe (I don't know if light box can do it or not but I think color box is similar to light box) and I override the page.tpl.php to my page to remove all region except my content

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.