Results 1 to 4 of 4

Thread: Modules load order

  1. #1
    New user
    Join Date
    03-02-10.
    Posts
    2

    Default Modules load order

    This is my first module an i found something strange.

    I create a module and named it "foo", and created "tl_news.php" under the "dca" folder and added these lines:

    Code:
    /**
     * Change tl_news palettes
     */
    $GLOBALS['TL_DCA']['tl_news']['palettes']['default'] = str_replace("author", "author,foo", $GLOBALS['TL_DCA']['tl_news']['palettes']['default']);
    
    
    $GLOBALS['TL_DCA']['tl_news']['fields']['foo'] = array
    (
    	'label'					=> &$GLOBALS['TL_LANG']['MSC']['foo'],
    	'inputType'				=> 'select',
    	'foreignKey'			=> 'tl_foo.name',
    	'sorting'				=> true,
    	'eval'					=> array('tl_class'=>'long')
    );
    but there was no change in the News palette :?
    Finally I found that the problem caused by the order that the modules are loading. cause my module starts with "F" and will be called before News module with "N" and therefore the array i defined will be overridden by News module.
    But when i change my module name to "XFOO", everything will be ok.

    it was kinda weird for me, so i though maybe i'm missing something. I'll be glad if you have any comment on this issue.

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Modules load order

    This is only happening because you are extending and existing module. Its not strange, this is an intended behaviour, you just have to work around it. you have to place the load order in the alphabetical range, so this is the trick.

    1. name your module folder something like this to place it AFTER the default module:
    news_myextension
    e.g.
    news_gallery
    news_addicon
    news_etc

    then you have the control to ensure its run AFTER the news module's DCA was loaded.

  3. #3
    New user
    Join Date
    03-02-10.
    Posts
    2

    Default Re: Modules load order

    Thanks for the answer.
    I faced another issue. As you said, i changed my module name to "news_foo". and also i added this line in config.php:

    Code:
    $GLOBALS['FE_MOD']['news']['newsreader'] = 'ModuleNewsReaderFoo'
    and overridded "parseArticles" method to fetch something from database and pass the value to template.
    so far so good, but when i install the "tags" extension, that line in my config.php will be overridden by the same line in "tags" extension and my module won't work anymore.
    so I'm wondering how can we prevent this type of extensions' conflict?

  4. #4
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Modules load order

    create another module called newsreaderfoo and point it to your module and use that instead of the normal reader...

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
  •