I received a feature request in the Splash module issue queue to offer Lightbox in addition to Thickbox as an option for displaying splash pages. I'm having a very difficult time figuring out how to do this because it appears that Lightbox2 is entirely link oriented - I can not find any way to invoke it from a javascript event (i.e. document.ready). Is there something I'm missing here or is this just not possible with Lightbox2?

Comments

stella’s picture

Check out the documentation at http://drupal.org/node/316727

Basically if the content you want to display in a lightbox is in a div like <div id="lightboxAutoModal" rel="lightmodal[|height: 50px;]"> then it will open up on page load. You can configure the height and width via the rel attribute.

tiato’s picture

I know you must be tiring of answering these questions but I too cannot get the lightbox to auto load whatsoever. I would like to auto load an image inside a lightbox when the page loads but figured I need to start at basics and try to generate any auto loaded lightbox so I aimed with attempting to auto load $messages to no avail.

I added the following to page.tpl.php:

<?php if ($show_messages && $messages): ?>
      <div id="lightboxAutoModal" style="display: none;" ><?php print $messages; ?></div>
<?php endif; ?>

The above does not work instead no messages are displayed unless I remove 'style="display:none;"' then I can see messages again on the page but there is no lightbox. Lightbox works fine, as it should, with images and modals which is really what I use it for but none of the auto load recommendations I have tried have worked.

Source does look like it's tagging the line I added in page.tpl.php but there is no lightbox-processed? Is this okay?

<div id="lightboxAutoModal" style="display: none;" ><div class="messages status">
<a href="/admin/settings/site-maintenance">Operating in off-line mode.</a></div>
</div>

I have also tried applying patch lightbox2_6x_294361.patch which added the following line to the end of lightbox.js:

  // Attach lightbox to any links with lightbox rels.
  Lightbox.initList();
    $('#lightboxAutoModal').triggerHandler('click');
};

I would really very much like to get this working. I love your lightbox module and i'm starting to think maybe something is conflicting with lightbox? I do use the jquery_update module, I do remember you asked someone about that, could this be my problem?

I'm using the following:
Drupal 6.14
Lightbox2 6.x-1.9
JQuery plugins 6.x-1.10
JQuery Update 6.x-1.1
Image Assist 6.x-3.x-dev
CTools 6.x-1.0
CCK 6.x-3.x-dev

I tried to avoid posting a Q but I have tried everything listed in the issues and the lightbox documentation to avoid posting a q but I am now at a loss. Thank you in advance for your help and thank you for bothering to code this module in the first place. It works great just the auto-load is a bit tricky, eh? :)

If you need more info let me know. Got tons. :)

stella’s picture

Any chance you could try the dev version?

tiato’s picture

Stella,

Thanks for your response, will def try the dev, give me a couple days and I'll post the outcome

tiato’s picture

Update:

I tried the dev version and sure enough AutoModal works fine with images inserted using img_assist, I couldn't get messages working but I neither needed it or spent as much time with. And it may be worth noting that not only is the AutoModal working I am using the Insert Node filter so my code to actually call the lightbox looks like follows:

<div id="lightboxAutoModal" rel="lightmodal">
[node:12 body]
</div>

Here are the contents of node 12:

<span class="inline inline-center"><a href="http://www.mydomain.com/content/about"><img src="http://www.mydomain.com/images/globe_480x353.png" alt="Welcome to MySite!" title="Welcome to MySite!"  class="image image-_original " width="480" height="353" /></a><span class="caption"><strong>Welcome to MySite!</strong></span></span>

Now the only thing I wonder is if the ability to click vertical/horizontal scrollbars on/off is planned for the future? eh? ;) not critical and I will not delay production for it plus I believe if I use 'rel=' to resize the AutoModal box it should be a band-aid fix at the least, yes? Also, rounded corners would be cool. For future reference of course.

Thanks stella, dev is working as expected. i should note that I did remove code below from my page.tpl.php file as I was getting a blank white Modal when the lines were in, set back to default:

<?php if ($show_messages && $messages): ?>
      <div id="lightboxAutoModal" style="display: none;" ><?php print $messages; ?></div>
<?php endif; ?>

changed to:

<?php if ($show_messages && $messages): ?>
      <?php print $messages; ?>
<?php endif; ?>

Thanks stella, you're fantastic

tiato’s picture

Quick question: Has this been committed to the latest version of Lightbox2 or should I keep using the dev version?

Thanks stella!

tiato’s picture

Status: Active » Fixed
tiato’s picture

Assigned: Unassigned » tiato

Status: Fixed » Closed (fixed)

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

Road Kill’s picture

Assigned: tiato » Unassigned
Status: Closed (fixed) » Active

I am trying to get a page to fire in a light box when somebody arrives at landing page of a website.

The light box works but appears to not respect the URL. Any suggestions or tips would be most appreciated.
My approach was the following but I think I might be missing something. I put the code below in a tpl the light box works but no joy with the URL.

<div id="lightboxAutoModal" style="display: none;" >
<a href= http://www.flushbathrooms.co.za/flush-promotion">TEST</a></div>
</div>
Road Kill’s picture

Okay I have been using the code below to call the node but I am actually trying to open the full node in the lightbox, but at the moment I have had to put text asking to click to view the full node this is not really desirable.

<div id="lightboxAutoModal" style="display: none;" >
<a href="node/1475/lightbox2" rel="lightframe"> Click to view promo</a>
</div>