Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Re: Media as a Page?

$
0
0

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;   
   }
}


Posted to: Media as a Page? | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles