Hey guys,
Sorry for the delay, I forgot to subscribe to this thread so didn't see your questions. Firstly:
Did you create your own theme template or modify an existing theme?
- No theme for that site just created it from scratch.
What module did you use on your home page for the flash photo gallery?
- That's not a module that's actually done in flash then just displayed as a .swf, I'm planning on redoing it in javascript but not a huge priority.
As to the more general questions about how I did it I won't post my actual code as it gets kinda tricky with the ajax, RSS and speaker selection but I'll post some code which will achieve the same effect but without the ajax, RSS and speaker dropdown menu.
I didn't use a module for the frontend, the objects are managed with the DataObjectManager module, this includes the flash player I put in the table. I am planning to post a couple of tutorials covering what all this means on the www.ssbits.com website but I've got exams this week so it'll have to wait sorry. But basically it consists of two php files, Message.php and MessagePage.php, then a MessagePage.ss template file.
This has pagination built into it but there is a good step by step of what that part of the code means here http://doc.silverstripe.org/doku.php?id=private:recipes:pagination
If you have any questions just ask (I'll subscribe this time) but otherwise this should pretty much just work :)
Cheers,
Howard
mysite/code/Message.php
<?php
class Message extends DataObject
{
static $db = array (
'Title' => 'Varchar',
'Speaker' => 'Varchar',
'Date' => 'Date',
'Duration' => 'Varchar'
);
static $has_one = array (
'Attachment' => 'File',
'MessagePage' => 'MessagePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new TextField('Speaker'),
new TextField('Duration','Duration: (MM:SS)'),
new DatePickerField('Date'),
new FileIFrameField('Attachment')
);
}
function Link(){
return $this->Attachment()->Filename;
}
}
?>
/mysite/MessagePage.php
<?php
class MessagePage extends Page {
static $has_many = array (
'Messages' => 'Message'
);
static $icon = 'mysite/images/icons/messages';
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Messages',
'Message', // Source class
'Attachment', // File name on DataObject
array(
'Title' => 'Title',
'Speaker' => 'Speaker'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$manager->setUploadFolder('/Messages/');
$f->addFieldToTab("Root.Content.Messages", $manager);
return $f;
}
}
class MessagePage_Controller extends Page_Controller {
function orderedMessages(){
//
// Change this to set the limit of messages displayed on each page //
//
$messageLimit = 10;
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$doSet = DataObject::get(
$callerClass = "Message",
$filter = "MessagePageID = $this->ID",
$sort = "Date DESC",
$join = "",
$limit = "{$SQL_start},$messageLimit"
);
return $doSet ? $doSet : false;
}
}
?>
/themes/mytheme/Layout/templates/MessagePage.ss
<!-- Main right column -->
$Content
<table id="messages">
<% control orderedMessages %>
<tr class="$EvenOdd $FirstLast">
<td class="message-date">$Date.Nice</td>
<td class="message-title">$Title<br />$Speaker <% if Duration %><span class="duration">($Duration mins)</span><% end_if %></td>
<% control Attachment %>
<td class="message-download"><a href="$Link">Download</a></td>
<td class="message-playnow">Play now:</td>
<td class="message-player">$Player</td>
<% end_control %>
</tr>
<% end_control %>
</table>
<% if orderedMessages.MoreThanOnePage %>
<p id="pagination-links">
<% if orderedMessages.NotFirstPage %>
<a href="$orderedMessages.PrevLink" class="ajax" title="Previous Page"><< Prev</a> |
<% end_if %>
<% control orderedMessages.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" class="ajax" title="Go to page $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<% if orderedMessages.NotLastPage %>
| <a href="$orderedMessages.NextLink" class="ajax" title="Next Page">Next >></a>
<% end_if %>
</p>
<% end_if %>
<!-- end Middle column -->