Results 1 to 3 of 3

Thread: postUpload Hook: how can I implement it?

  1. #1
    New user
    Join Date
    05-19-11.
    Posts
    22

    Default postUpload Hook: how can I implement it?

    Hi community

    I'd like to use the php imagick extension in order to create a jpg image from a uploaded pdf file. (see http://php.net/manual/en/book.imagick.php)

    I figured that the a right way to do so would be to use the postUpload hook.

    However, I never used Contao Hooks and can't figure out how to do it...

    I added
    Code:
    $GLOBALS['TL_HOOKS']['postUpload'][] = array('MyClass', 'myPostUpload');
    to \system\config\dcaconfig.php

    but I got the following error
    Code:
    Warning: in_array() expects parameter 2 to be array, null given in system\modules\core\library\Contao\System.php on line 140
    #0 [internal function]: __error(2, 'in_array() expe...', 'C:\Program File...', 140, Array)
    #1 system\modules\core\library\Contao\System.php(140): in_array('getInstance', NULL)
    #2 system\modules\core\drivers\DC_Folder.php(975): Contao\System->import('MyClass')
    #3 system\modules\core\classes\Backend.php(650): Contao\DC_Folder->move()
    #4 system\modules\core\controllers\BackendMain.php(131): Contao\Backend->getBackendModule('files')
    #5 contao\main.php(20): Contao\BackendMain->run()
    #6 {main}
    
    Fatal error: Class 'MyClass' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\mysite\system\modules\core\library\Contao\System.php on line 140
    Not surprisingly, since I dont know where to save MyClass.php
    Code:
    // MyClass.php
    
    public function myPostUpload($arrFiles)
    {
        // Do something
    
    
    }
    Could someone help me out on this one?
    Edit : Contao version is 3.5.14

    Thanks a lot
    Vinny
    Last edited by vinny38; 07/25/2016 at 11:44.

  2. #2
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Did you try to declare it in Functions.php

    /system/helper/
    Last edited by tetrijeb; 08/02/2016 at 01:03.

  3. #3
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    No, never change core files.

    Create your own extension from within backend by using the Extension-Creator. Then you will have a skeleton of a new extension.

    Look into those files. The Hook goes to system/modules/my-hooks/config/config.php. Your class goes to system/modules/my-hooks/classes/myHooks.php.

    Also take a look into other core extensions to see how things are done.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •