Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Convert Absolute URL to encodeurl Absolute URL

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

Page: 1
Go to End
Author Topic: 330 Views
  • thomas.paulson
    Community Member
    79 Posts

    Convert Absolute URL to encodeurl Absolute URL Link to this post

        <% with $Magazine %>
        <iframe src="http://docs.google.com/viewer?url={$Document.AbsoluteURL}&embedded=true" width="100%" height="842"></iframe>
        <% end_with %>

    if you check the above code, it print url as 'http://localhost/masapulari/assets/Uploads/dummy.pdf .
    Magazine is a DataObject class and Document is File Type, as you see below.
    Is there a way to print urlencode of $Document.AbsoluteURL?

    class Magazine extends DataObject {

       private static $db = array(
        'Date' => 'Date',

       private static $has_one = array(
        'Photo' => 'Image',
        'Document' => 'File'

    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 (

       public function init() {

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work

       public function view(){
        $params = $this->getURLParams();
        $id = (int)$params['ID'];
        $data = $this->Magazine($id);   
        return $this->customise(array(
        ))->renderWith(array( 'Magazine', 'Page'));    
       public function Magazine($id){
        $data = DataObject::get_by_id('Magazine',$id);       
        return $data;   

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.