Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DOM Lightbox shows '1 of 6' even though only 1 image

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1571 Views
  • pinkp
    Avatar
    Community Member
    168 Posts

    DOM Lightbox shows '1 of 6' even though only 1 image Link to this post

    EDIT: Perhaps there is a better way to use ImageGallery Lightbox on other Page types, then my example below..?

    I've altered the DOM example "Testimonials" to include an image field and added the lightbox effect from ImageGallery which is working great apart from one thing...

    The lightbox pop-up shows "1 of 6" when there is only one image. Clicking next takes you through the same image six times.

    Adding another entry creates "1 of 11", I can't work it out, can someone help? thanks!

    These are my files for my EventPage page type (apologies for the long entry):

    EventPage.ss

    <link rel="stylesheet" type="text/css" href="image_gallery/gallery_ui/lightbox/css/jquery.lightbox-0.5.css" />
    <link rel="stylesheet" type="text/css" href="/image_gallery/css/ImageGallery.css" />
    </ul>
    <div id="Content" class="typography">
    <% if Level(2) %>
    <div class="breadcrumbs">
    $Breadcrumbs
    </div>
    <% end_if %>         
    $Content
    $Form
       <div id="EventsList"><ul>
                <% control Events %>
                <li id="Events">
                      <div id="EventTitle"><h3><% if Link %><a href="http://$Link" target="_blank" alt="$Title">$Title</a><% else %>$Title<% end_if %></h3></div>
                      <div id="EventDescription"><p>$Description</p></div>
                      <div id="EventLocation">$Location</div>
                      <div id="EventDate">$Date.Nice</div>
           <% if Flyer %><div id="EventImage"><a rel="lightbox" class="lightbox" title="$Title" href="$Flyer.URL">
                      <% control Flyer.SetWidth(130) %>
                   <img src="$URL"<% end_control %>alt="$Title"/><% end_if %>
    </div>
                      
                   <div id="Item">

                </li>
                <% end_control %>
                </ul></div>
    </div>
    <script type="text/javascript" src="jsparty/jquery/jquery.js"></script>
    <script type="text/javascript" src="image_gallery/gallery_ui/lightbox/javascript/jquery.lightbox-0.5.js"</script>
    <script type="text/javascript" src="image_gallery/gallery_ui/lightbox/javascript/lightbox_init.js"></script

    EventPage.php

    <?php
    class EventPage extends Page
    {
       static $has_many = array (
          'Events' => 'Event'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new DataObjectManager(
             $this, // Controller
             'Events', // Source name
             'Event', // Source class
             array('Date' => 'Date', 'Title' => 'Title', 'Link' => 'Link', 'Location' => 'Location & Time', 'Description' => 'Description', 'Flyer' => 'Flyer'), // Headings
             'getCMSFields_forPopup' // Detail fields function or FieldSet
             // Filter clause
             // Sort clause
             // Join clause
          );
          
          
          $f->addFieldToTab("Root.Content.Events", $manager);
          
          return $f;
       }

    }
    class EventPage_Controller extends Page_Controller
    {
    }
    ?>

    Event.php

    <?php
    class Event extends DataObject
    {
       static $db = array (
          'Date' => 'Date',
          'Title' => 'Text',
          'Link' => 'Text',
          'Location' => 'Text',
          'Description' => 'Text'
       );
       
       static $has_one = array (
          'EventPage' => 'EventPage',
                'Flyer' => 'Image'

       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new CalendarDateField('Date'),
             new TextField('Title'),
             new TextField('Link'),
             new TextField('Location'),
             new TextareaField('Description'),
             new ImageField('Flyer')
          );
       }
    }
    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM Lightbox shows '1 of 6' even though only 1 image Link to this post

    Is this a bug with DOM or ImageGallery?

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: DOM Lightbox shows '1 of 6' even though only 1 image Link to this post

    Well im using the DOM mod but including the Lightbox from ImageGallery for images in my DOM page...

    Really I'm asking for the best way to use Lightbox from Image Gallery on other Page Types I know there is other posts but none seem to answer in full. I have this working but the image count is wrong... maybe my .ss but havn't found it yet.

    missing a </a> in the .ss ................ what can I say dumb. Sorry!

    1571 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.