Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Files & Images Administraction do not work after i extend image class

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1535 Views
  • msantang
    Avatar
    Community Member
    41 Posts

    Files & Images Administraction do not work after i extend image class Link to this post

    Hi here is my code in Producto.php, is a little change from the "extend a basic site" tutorial. (staff part)

    class Producto extends Page {
       static $db = array(
       );
       static $has_one = array(
       'Foto' => 'ProductPage_Image'
       );

       function getCMSFields() {
          $fields = parent::getCMSFields();

          $fields->addFieldToTab("Root.Content.Images", new ImageField('Foto'));
          return $fields;
       }
    }

    class Producto_Controller extends Page_Controller {

    }

    class ProductPage_Image extends Image {
       function generateThumbnail(GD $gd, $width, $heigth) {
          $gd->setQuality(90);
          return $gd->paddedResize($width,$heigth,"F0F0F0");
       }
       
       public function Thumbnail($width)
       {
          return $this->getFormattedImage('Thumbnail',$width, 70);
       }
    }

    i create a few page of this type and add images to every product.
    All this works perfect in live site, Thumbnail are created perfect.

    But in CMS when click "Files & Images" i get : Fatal error: Class 'ProductPage_Image' not found in D:\...\sapphire\core\model\DataObject.php on line 1096

    Why i get this error?

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Files & Images Administraction do not work after i extend image class Link to this post

    Have you tried entering the admin panel doing ?flush=1 at the end of the URL? Perhaps there is some caching somewhere.

    eg. http://www.mysite.com/admin?flush=1

    also, try: http://www.mysite.com/db/build?flush=1 in case there's something missing.

    Hopefully that should shed some light on the situation.

    Cheers,
    Sean

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Files & Images Administraction do not work after i extend image class Link to this post

    The class ProductPage_Image *must* be in a file called ProductPage.php

    If you want to put it into Producto.php, you should rename the class to Prodocto_Image. If you do this, remember to run db/build, and then edit the current images in the database, changing the File.ClassName field.

  • msantang
    Avatar
    Community Member
    41 Posts

    Re: Files & Images Administraction do not work after i extend image class Link to this post

    I will fix it and tell you the results.

    Thanks.

    And Great Work with this CMS, and tanks to open it to the community.

  • msantang
    Avatar
    Community Member
    41 Posts
    1535 Views
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.