CodeIgniter Forums
Modular Extensions - Version 4.3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Modular Extensions - Version 4.3 (/showthread.php?tid=6550)



Modular Extensions - Version 4.3 - El Forum - 07-11-2008

[eluser]sophistry[/eluser]
wow! that's all it was? i looked at the load_class() function and it seemed to have some logic to stop re-loading classes that had already been loaded. i guess there was something else going on.

so, in case you were wondering... i made the patches and i now have a working ME system in place! running on PHP4.

i feel like a kid on christmas eve making plans for all the new toys. ;-) hmnnn... which module shall i build out first? which of them is the best candidate for testing nesting capabilities? how can i restructure an existing app to break off some pieces into a module? ah... the possibilities. i'll try to make some wiki changes as i go along learning this thing so that others may benefit in my wake.

thanks for all your work on this cool tool wiredesignz, i'll let you know how it goes.


Modular Extensions - Version 4.3 - El Forum - 07-11-2008

[eluser]wiredesignz[/eluser]
You're welcome sophistry and thanks for your input, you make the community a better place by contributing too.

Cheers


Modular Extensions - Version 4.3 - El Forum - 07-12-2008

[eluser]Chicken's Egg[/eluser]
May be I'm going to ask a very silly question - in that case forgive me being a newbie - but how do you separate front- and back-end (admin-section) using modules?

Background of this question:
I am thinking of a website where pages and content get separated. So when calling for www.mydomain/page/ I would like to route this url to my default controller. This controller looks in a database which modules are used to create the content of this page, calls the controllers of those modules to receive the content, puts it together and finally displays the page as requested. I think this can be done with Modular Extensions. But, this is a description of the frond-end of the application. And before that can ever work, I must have a way to create the content-blocks and pages first. And that's where I'm stuck. I searched this forum and the wiki and have read a lot of good things about this project. But unfortunately I didn't find the answer.

[edit]
I finally found a post I can use, all-though this solution means that I have to write two separate applications. I would rather use one application.

PS
Would it be a good idea to create hyperlinks from the wiki-page to some of this forum threats. I'm thinking on a list like Edemilson Lima posted.
[/edit]


Modular Extensions - Version 4.3 - El Forum - 07-12-2008

[eluser]Chicken's Egg[/eluser]
Is the wiki information about loading a language file correct? I get an error when I use the example: "Fatal error: Call to undefined method Modules::find() in C:\server\web\CI\edward\backend\libraries\Controller.php on line 240". I downloaded version 4.2.03 (2008-07-04) from the Wiki-page today.

I have got one module called welcome. It has got one controller

Code:
<?php
// Base Controller activeren
include(APPPATH . 'controllers/base_controller.php');

class Welcome extends Base_controller {

    function __construct()
    {
      // Parent class meeladen
      parent::__construct();
    }
    
    function index()
    {
      // Taal ophalen:
      $this->sLanguage = $this->config->item('language');  // Taal ophalen
      // Algemeen taalbestand inladen
      $this->load->language('home');

      // Main view laden
      $this->load->view('main',$this->data);
    }
}

For those who wonder what the base_controller file looks like:

Code:
<?php
class Base_controller extends Controller{

  var $view_dir;               // Submap waar de views in staan.
  var $data = array();         // Array om data op te slaan.
  protected $iUrl_segment;     // Segment voor menu hightlight

  function __construct()
  {
    // Sessie starten:
    session_start();

    // Error reporting:
    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    // Controller meeladen
    parent::Controller();

    // Taal instellen
    if(!isset($_SESSION['taal']))
    {
      $_SESSION['taal'] = 'nl';
    }

    // Taal vasstleggen:
    $aTalen = array(
      'nl' => 'dutch',
      'en' => 'english',
      'fr' => 'french',
      'de' => 'german');
    $this->config->set_item('language', $aTalen[$_SESSION['taal']]);


    // Vastgestelde teksten:
    $this->data['meta_language']   = $_SESSION['taal'];
//    $this->data['meta_charset']    = 'utf-8';
    $this->data['meta_charset']    = 'iso-8859-1';
    $this->data['meta_index']      = 'noindex';
    $this->data['meta_follow']     = 'nofollow';
    $this->data['meta_css_screen'] =  $this->config->item('media_css') . 'admin/admin_default.css';
    $this->data['meta_title']      = 'Admin Panel';

  }



Modular Extensions - Version 4.3 - El Forum - 07-12-2008

[eluser]wiredesignz[/eluser]
Thanks Chicken's Egg, you discovered a typo/bug in 4.2.03 language loader Wink

Modular Extensions version 4.2.04 (bugfix) is available on the wiki now.


Modular Extensions - Version 4.3 - El Forum - 07-13-2008

[eluser]Chicken's Egg[/eluser]
[quote author="wiredesignz" date="1215924636"]Thanks Chicken's Egg, you discovered a typo/bug in 4.2.03 language loader Wink[/quote]
I'm glad I could help, allthough I found it by accident. You are amazing fast with the bugfixes wiredesignz. Thank you so much!


Modular Extensions - Version 4.3 - El Forum - 07-13-2008

[eluser]Chicken's Egg[/eluser]
I got an other fatal error.
Code:
Fatal error: Call to undefined method Modules::method() in C:\server\web\CI\edward\backend\helpers\modules_helper.php on line 210
The bad news is: line 210 doesn't exist as the modules_helper.php has got 172 lines.

To reproduce this error:
- Create a module called modules.
- Add the following line in your view-file.
Code:
<?php
  // Load menu:
  echo modules::run('modules', $data, 'module_list');
  ?>
- Show this view-file loaded by an other controller. In my case the default controller is home. So I added this line in the view of 'home' to recieve some content of the module 'modules'.

I thought this would call the function module_list of the module modules. But it doesn't. And if I change the name of my module to 'test' it gives me an other error: "Fatal error: Cannot redeclare class Base_controller in C:\server\web\CI\edward\backend\controllers\base_controller.php on line 64". Line 64 is nearly the last line of the class base_controller. It only contains a }-character. Line 65 contains "?>". It's obvious that I still have a long way to go, before I can write any modular application.

Used code

Controller - Base_controller:
Code:
<?php
class Base_controller extends Controller{

  public $data = array();      // Array to store content
  protected $iUrl_segment;     // Segment voor menu hightlight

  function __construct()
  {
    // Start session
    session_start();

    // Error reporting:
    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    // Load controller
    parent::Controller();
  }

  public function main_view()
  {
    // Show main view:
    $this->load->view('main',$this->data);
  }
}
?>

Controller - home:
Code:
<?php
// Base Controller activeren
include(APPPATH . 'controllers/base_controller.php');

class Home extends Base_controller {

    function __construct()
    {
      // Parent class meeladen
      // Uitvoeren:
      // - Hoofdmenu inbouwen
      // - Standaard teksten vastleggen.
      parent::__construct();

    }
    
    function index()
    {
      // Getting language
      $this->sLanguage = $this->config->item('language');  // Taal ophalen
      // Load default language file
      $this->load->language('welcome',$this->sLanguage);

      $this->data['content']  = '';
      $this->data['sub_menu'] = '';

      // Load main view
      $this->main_view();
    }
}

Controller - test
Code:
<?php
// Base Controller activeren
include(APPPATH . 'controllers/base_controller.php');

class Test extends Base_controller{

    function __construct()
    {
    }
    
    function index()
    {
    }

    function module_list()
    {
       echo 'test';
    }
}

Removing 'extends base_controller' from the test-controller won't make the error to disappear.


Modular Extensions - Version 4.3 - El Forum - 07-13-2008

[eluser]wiredesignz[/eluser]
Ok, Modules is a reserved word in ME, the Modules class is inside modules_helper.php begining at line 191, so you cannot define your own Modules class also.

You are also getting “Fatal error: Cannot redeclare class Base_controller" error because you are attempting to include your Base_controller in each controller class. try using require_once instead.


Modular Extensions - Version 4.3 - El Forum - 07-13-2008

[eluser]Chicken's Egg[/eluser]
[quote author="wiredesignz" date="1215956000"]Ok, Modules is a reserved word in ME[/quote]
If you don't mind I will add that to the wiki aswell.

[quote author="wiredesignz" date="1215956000"]You are also getting “Fatal error: Cannot redeclare class Base_controller" error because you are attempting to include your Base_controller in each controller class. try using require_once instead.[/quote]
That did the trick, I should have though of that myself. Shame on me. If you like I can create a new page on the wiki concerning this kind of problems for starters though.


Modular Extensions - Version 4.3 - El Forum - 07-13-2008

[eluser]wiredesignz[/eluser]
Yes please, anything relevant to Modular Extensions can be added to the wiki.