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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Uncaught Exception: Object->__call(): the method 'backlinktracking' does not exist on 'PdfFile'


Reply


6 Posts   1565 Views

Avatar
escaped

Community Member, 6 Posts

16 November 2009 at 11:04am

Hello,

I want to use the FileDataObjectManager with a Special Filetype, cause i need some additional functions for the uploaded pdf file.

my DataObject (ResourceFile.php):

class ResourceFile extends DataObject {
   static $db = array (
      'Name' => 'Text',
      'Description' => 'Text',
   );
   
   static $has_one = array (
      'pdf' => 'PdfFile',
      'DocumentsPage' => 'DocumentsPage'
   );
   
   public function getCMSFields_forPopup() {
      $pdfFile = new FileIFrameField('pdf');
      $pdfFile->setAllowedExtensions(array('pdf'));
      
      return new FieldSet(
         new TextField('Name'),
         new TextareaField('Description'),
         $pdfFile,
      );
   }
}

DocumentsPage.php:

class DocumentsPage extends Page {

   static $has_many = array(
      'Documents' => 'ResourceFile'
   );
   
   public function getCMSFields() {
      $f = parent::getCMSFields();
      $manager = new FileDataObjectManager(
         $this, // Controller
         'Documentss', // Source name
         'ResourceFile', // Source class
         'pdf', // File name on DataObject
         array(
            'Name' => 'Name',
            'Description' => 'Description',
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );
$manager->setBrowseButtonText("Upload (pdf only)");
$manager->setAllowedFileTypes(array('pdf'));
                  
      $f->addFieldToTab("Root.Content.Documents",$manager);

      return $f;
   }
}

class DocumentsPage_Controller extends Page_Controller {
}

Even if i use the following PdfFile.php, i get this error, wenn i try to import a PDF (from Upload folder) in Backend:

class PdfFile extends File {
   function BackLinkTracking() {
      return false;
   }
}

I have no idea what is wrong. Hopefully someone can help me.

Thanks

escaped

Avatar
escaped

Community Member, 6 Posts

16 November 2009 at 11:07am

Using ss 2.3.3 and latest version of DataObjectsManager. (r324).

Avatar
UncleCheese

Forum Moderator, 4094 Posts

16 November 2009 at 11:56am

You have a typo here:

'Documentss', // Source name

Avatar
UncleCheese

Forum Moderator, 4094 Posts

16 November 2009 at 12:52pm

This is weird. The bug was resolved a while back here:

http://www.silverstripe.org/dataobjectmanager-module-forum/show/269282?start=24

But I think some revisions to the way imports are handled undid that change. Please change line 534 of FileDataObjectManager.php to:

            if($this->fileClassName != "File" && $file->ClassName != $this->fileClassName) {
               $file = $file->newClassInstance($this->fileClassName);
               $file->write();
            }

And let me know if that solves your problem. If it does, I'll check in the change. Thanks.

Avatar
escaped

Community Member, 6 Posts

16 November 2009 at 9:56pm

perfect! it works :)

thanks you!

escaped

Avatar
UncleCheese

Forum Moderator, 4094 Posts

17 November 2009 at 2:07am

Great. I'll check in the change.