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')
);
}
}
?>