Hey,
Sorry about the late reply here I didn't have a netz while I was in Venice :S
MyImageGalleryPage.php:
<?php
/**
* Defines the MyImagegalleryPage page type
*/
class MyImageGalleryPage extends ImageGalleryPage {
protected $albumClass = "MyImagegalleryAlbum";
public function PostPhotographer()
{
return $this->CurrentAlbum()->Photographer;
}
public function PostVenue()
{
return $this->CurrentAlbum()->Venue;
}
}
class MyImageGalleryPage_Controller extends Page_Controller {
public function init()
{
parent::init();
Requirements::css('image_gallery/css/ImageGallery.css');
}
protected function adjacentAlbum($dir)
{
$t = $dir == "next" ? ">" : "<";
$sort = $dir == "next" ? "ASC" : "DESC";
return DataObject::get_one(
$this->albumClass,
"ImageGalleryPageID = {$this->ID} AND SortOrder $t {$this->CurrentAlbum()->SortOrder}",
false,
"SortOrder $sort"
);
}
public function NextAlbum()
{
return $this->adjacentAlbum("next");
}
public function PrevAlbum()
{
return $this->adjacentAlbum("prev");
}
}
?>
MyImageGalleryAlbum.php:
<?php
/**
* Defines the MyImageGalleryAlbum page type
*/
class MyImageGalleryAlbum extends ImageGalleryAlbum {
static $db = array (
'AlbumDate' => 'Date',
'Photographer' => 'Text',
'Venue' => 'Text'
);
static $has_one = array (
'EventHeader' => 'Image'
);
public function getCMSFields_forPopup() {
$f = parent::getCMSFields_forPopup();
$f->push(new CalendarDateField('AlbumDate','Date of Event'));
$f->push(new TextField('Photographer','Name of Photographer'));
$f->push(new TextField('Venue','Event Venue'));
$f->push(new ImageField('EventHeader','Event Header', null, null, null, 'assets/Uploads/'));
return $f;
}
}
?>
themes/main/templates/Layout/MyImageGalleryPage_album.ss:
$EventHeader
<div id="Content" class="typography">
<div id="ContentPad">
<% if Albums %>
<% end_if %>
<h5>$AlbumTitle<span class="album-info"> by $PostPhotographer</span></h5>
<p class="articleDate"><strong>Venue:</strong> $PostVenue</p>
<p class="articleDate">$AlbumDate.Long</p>
$GalleryLayout
<div class="album-nav">
<ul>
<% if PrevAlbum %>
<% control PrevAlbum %>
<li class="prev">
<div class="album-nav-img"><a href="$Link" title="<% sprintf(_t('GOTOALBUM','Go to the %s album'),$AlbumName) %>">$CoverImage.SetWidth(50)</a></div>
<div class="album-nav-desc">
<h4><% _t('PREVIOUSALBUM','Previous Album') %>:</h4>
<a href="$Link" class="album-link">$AlbumName</a>
</div>
</li>
<% end_control %>
<% end_if %>
<% if NextAlbum %>
<% control NextAlbum %>
<li class="next">
<div class="album-nav-img"><a href="$Link" title="<% sprintf(_t('GOTOALBUM','Go to the %s album'),$AlbumName) %>">$CoverImage.SetWidth(50)</a></div>
<div class="album-nav-desc">
<h4><% _t('NEXTALBUM','Next Album') %>:</h4>
<a href="$Link" class="album-link">$AlbumName</a>
</div>
</li>
<% end_control %>
<% end_if %>
</ul>
</div>
<% if GalleryItems.MoreThanOnePage %>
<ul id="pagination-imagegallery">
<% if GalleryItems.NotFirstPage %>
<li class="previous"><a title="<% _t('VIEWPREVIOUSPAGE','View the previous page') %>" href="$GalleryItems.PrevLink">«<% _t('PREVIOUS','Previous') %></a></li>
<% else %>
<li class="previous-off">«<% _t('PREVIOUS','Previous') %></li>
<% end_if %>
<% control GalleryItems.Pages %>
<% if CurrentBool %>
<li class="active">$PageNum</li>
<% else %>
<li><a href="$Link" title="<% sprintf(_t('VIEWPAGENUMBER','View page number %s'),$PageNum) %>">$PageNum</a></li>
<% end_if %>
<% end_control %>
<% if GalleryItems.NotLastPage %>
<li class="next"><a title="<% _t('VIEWNEXTPAGE', 'View the next page') %>" href="$GalleryItems.NextLink"><% _t('NEXT','Next') %> »</a></li>
<% else %>
<li class="next-off"><% _t('NEXT','Next') %> »</li>
<% end_if %>
</ul>
<% end_if %>
<% if Albums %>
<% end_if %>
</div>
</div>
<div id="ContentFoot">
<div id="backNav"><a href="#">Return to Main Photos Page</a></div>
</div>
Sorry about the massive post.
What I have found is that when I call the value $AlbumDate in themes/main/templates/Includes/AlbumList.php (included in MyImageGalleryPage.ss) then the value is called to the page perfectly. But when I try to do it to MyImageGalleryPage_album.ss it won't work unless I create the function in the relative MyImageGalleryPage.php file as shown above.
EDIT: I've just stumbled across this right now. If I used
<% control Albums %><% end_control %>
I can call the values correctly. But of course it calls all the values for all of the albums...