21278 Posts in 5728 Topics by 2599 members
General Questions
SilverStripe Forums » General Questions » Files as pages (using KickAssets) and how to set current state?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 321 Views |
-
Files as pages (using KickAssets) and how to set current state?

25 April 2012 at 2:12am Last edited: 25 April 2012 2:14am
This info below might be useful to someone doing something similar, but just skip to the two questions below it if you like:
- - - - - -
I'm using Uncle Cheese's KickAssets module to add multiple Images to pages. Then I'm attempting to show them individually on the page with thumbnails and links to next/previous.Using Kickassets the Photos are just files (as opposed to a new Dataobject)
static $many_many = array (
'Photos' => 'File'
);
So I'm using the Datobjects as pages technique but instead of calling a data object I'm calling the File by its ID in the URL eg. /show/165public function getPhoto()
{
$Params = $this->getURLParams();if(is_numeric($Params['ID']) && $Photo = DataObject::get_by_id('File', (int)$Params['ID']))
{
return $Photo;
}
}This is working perfectly (after many failed attempts) - and in my template I can show the current photo using
<% control Photo %>
<img src="$URL" alt="$Title" />
<% end_control %>In order to show the thumbnails I call all the Photos belonging to this page:
public function ShowPhotos($limit = null) {
$data = $this->getManyManyComponents('Photos', '', 'ManyManySort', '', $limit);
return $data;
}And on my template
<% control ShowPhotos %>
<a href="$Top.URLSegment/show/$ID" id="$Top.Photo.ID"><img src="$URL" alt="$Title" /></a>
<% end_control %>So far so good (and the above might be useful to someone trying to do similar)
- - - - - -
Question 1
- - - - - -
But I'd like to know how to highlight the current thumbnail, because $LinkingMode won't work for files … essentially I need to do this<% if ID=Top.Photo.ID %>class=current<% end_if %>
but this doesn't work - so how would I write that as a function I can call from inside this ShowPhotos control loop?- - - - - -
Question 2
- - - - - -
What's the best way to call the next and previous file links?Any suggestions or advise on this would be greatly appreciated, thanks.
| 321 Views | ||
|
Page:
1
|
Go to Top |

