Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Adding images to pages and silverstripe 3.1

$
0
0

In order to add an image to a page type, I used the following code in silverstripe 3.0 but the same code (after changing public static to private static) does not display the image in silverstripe 3.1

In ContentPage.php

<?php
class ContentPage extends Page {
   private static $db = array(
   );
   private static $has_one = array(
      'Photo' => 'Image'
   );
   public function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Images", new UploadField('Photo'));
      return $fields;
   }
}
class ContentPage_Controller extends Page_Controller {}

on ContentPage.ss

<% if Photo %><div class="pollaroid-Blog">$Photo.SetWidth(250)</div><% end_if %>

Am I missing something that needs to be changed to get this to work in Silverstripe 3.1


Posted to: Adding images to pages and silverstripe 3.1 | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles