ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Modular Extensions - Version 4.3

March 03, 2008 6:10pm

Subscribe [48]
  • #571 / Jul 21, 2008 7:11pm

    Sam Dark

    242 posts

    Switched to 4206 from 5025 just to test.
    Seems issues with config loading are now fixed. That’s very good.

    Found a bug. Modular controller method is running twice.

    /modules/test/controllers/index.php

    <?php
    class Index extends Controller {
      function index(){
        print 'CALL'."<br>";
      }
    }

    prints

    CALL
    CALL
  • #572 / Jul 21, 2008 8:38pm

    wiredesignz

    2882 posts

    @Sam, If you have a controller class named Index it’s constructor will be run twice as you see, because CI uses index() as the default entry point to the controller and of course it is the constructor also. This is a CI thing, and not related to ME.

  • #573 / Jul 22, 2008 5:18am

    freshface

    131 posts

    A best practice question.
    Is the best use of ME to load it in a controller? (controllers/front.php)
    Or in modules/front/controllers/front.php

    Or just call the module in controllers/front.php

  • #574 / Jul 22, 2008 5:31am

    Sam Dark

    242 posts

    @wiredesignz, thanks! Forgot about PHP4 constructors… again :(

  • #575 / Jul 22, 2008 5:47am

    wiredesignz

    2882 posts

    @freshface, There is no best practice. Try all methods, see which works for you.

  • #576 / Jul 22, 2008 12:20pm

    Stylec

    14 posts

    Hi, I’m having a problem with the modules::run . My structure is as follows -

    modules

    - admin
    —controllers
    —- admin.php

    - news
    —controllers
    —- admin.php
    —- news.php

    Using modules::run to call a method in news/controllers/news.php, this works fine but when I try using

    modules::run('news/controllers/admin', $data, 'adminPanelBlock');
    I get an error
    Unable to run the requested module: news/controllers/admin->adminPanelBlock

    Thanks for any help.

  • #577 / Jul 22, 2008 5:35pm

    freshface

    131 posts

    And without controllers?

    modules::run('news/admin', $data, 'adminPanelBlock');
  • #578 / Jul 22, 2008 6:17pm

    Stylec

    14 posts

    No that doesn’t work although it generates a different error

    Unable to locate the requested file: application/modules/news/methods/adminPanelBlock.php
  • #579 / Jul 22, 2008 8:41pm

    wiredesignz

    2882 posts

    @Stylec, Try using lowercase method names.

  • #580 / Jul 22, 2008 8:58pm

    Stylec

    14 posts

    No that doesn’t work either. Still same errors as before.

  • #581 / Jul 22, 2008 9:06pm

    wiredesignz

    2882 posts

    @Stylec, Please post the controller code.

  • #582 / Jul 23, 2008 9:25am

    Stylec

    14 posts

    admin/views/index.php

    <!-- Admin Home Page -->
    <h1>Overview</h1>
    <div id="left-block">
    
        <?php
        foreach ($modules as $row)
        {
            echo '<div id="block-management">';
            echo '<h2>' . $row->name . '</h2><p>';<br />
            echo modules::run('news/controllers' . '/admin', '', 'adminpanelblock'); <br />
            echo '</div>';<br />
        }<br />
        ?><br />
            <br />
    </div

    news/controllers/admin.php

    class Admin extends Controller {
            
            function Admin()
            {
                parent::Controller();
            }
            
            function adminpanelblock()
            {
                echo 'News :: Admin';
            }
        }

    Thanks.

  • #583 / Jul 23, 2008 9:34am

    wiredesignz

    2882 posts

    Hi Stylec, Try:

    <?php
        foreach ($modules as $row)
        {
            echo '<div id="block-management">';
            echo '<h2>' . $row->name . '</h2><p>';<br />
            echo modules::run('news/admin', '', 'adminpanelblock'); <br />
            echo '</div>';<br />
        }<br />
        ?>

  • #584 / Jul 23, 2008 9:36am

    Stylec

    14 posts

    That generates

    Unable to locate the requested file: application/modules/news/methods/adminpanelblock.php

    Does that suggests that news/controllers/admin is correct?

  • #585 / Jul 23, 2008 9:50am

    wiredesignz

    2882 posts

    The error suggests that modules::run has loaded admin.php but can’t locate adminpanelblock() and has tried to load a module/methods library before failing.

    Are you sure there aren’t any other admin.php controllers in the search path?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases