Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Media as a Page?


Go to End


4 Posts   618 Views

Avatar
richardtallent

Community Member, 5 Posts

26 May 2014 at 3:02am

My SilverStripe site is a genealogy web site, so I have a ton of high-resolution scanned documents (mostly PDFs and JPEGs) that I want to include.

Is there some sort of add-on or option I can use to create pages for these that directly link to the media rather than embedding them (resized) inside a normal page template?

I know a redirector page would probably do the trick, but I'd rather do it, if possible, without browser redirection and without the two-step process of uploading the media and separately creating a page for it.

Avatar
martimiz

Forum Moderator, 1391 Posts

26 May 2014 at 6:23am

Edited: 26/05/2014 6:23am

You could use a RedirectorPage, and instead of pointing it to another page on the site, select the option to point to another website, and enter the url of the pdf.

If you wanted to implement a dropdown to select the pdf, or other media, extend the RedirectorPage class...

Avatar
thomas.paulson

Community Member, 107 Posts

26 May 2014 at 5:59pm

i recently developed a website for magazine, they had there magazine in pdf format, i used the view the pdf

mysite/_config/routes.yml

Name: myroutes
After: framework/routes#coreroutes
---
Director:
rules:
'edition//$Action/$ID/$Name': 'Magazine_Controller'

mysite/code/Magazine_Controller.php
--------------------

<?php
class Magazine_Controller extends Page_Controller {

/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
private static $allowed_actions = array (
'index','view'
);

public function init() {
parent::init();

}

public function view(){
$params = $this->getURLParams();
$id = (int)$params['ID'];

$data = $this->getMagazine($id);

//Debug::message("Wow, that's great");

return $this->customise(array('Title'=> $data->getField('Title') , 'Magazine'=> $data )
)->renderWith(array( 'Magazine', 'Page'));
}

public function getMagazine($id){
$data = DataObject::get_by_id('Magazine',$id);
return $data;
}
}

Avatar
richardtallent

Community Member, 5 Posts

26 May 2014 at 6:49pm

Thanks!

I've extended Page to create a new DocumentPage type without the sidebar menu and with a single IMG / OBJECT tag.

While it's still not the entire browser width, it's a start.

Now I'm having a separate problem with JQuery, but I've moved to a new thread since it's only tangentially related.