Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Version 4.3

[eluser]wiredesignz[/eluser]
Thanks, I'll add this change to version 4.0.27

[eluser]Daeli[/eluser]
Is there a chance to use callback function in validation rules?

[eluser]wiredesignz[/eluser]
Yes you can use my Validation callbacks into Models extension, it also works with Modules. Good Luck.

http://codeigniter.com/wiki/MY_Validatio...to_Models/

[eluser]Daeli[/eluser]
[quote author="wiredesignz" date="1208447034"]Yes you can use my Validation callbacks into Models extension, it also works with Modules. Good Luck.

http://codeigniter.com/wiki/MY_Validatio...to_Models/[/quote]

There is a bug in MY_Validation library when you use Modular Extensions

On line 127:
Code:
if (!method_exists($this->CI->$class, $method))
   {        
      continue;
   }

The loaded Models are only stored in the Module wich loaded it...

[eluser]wiredesignz[/eluser]
Yes thats right, the callback would need to be into the Module Controller, not the Module Model.

However that extension could easily be modified to use a Module Model. I'll look into that at some stage. Thanks.

[eluser]Daeli[/eluser]
Tell me how then please Smile

[eluser]wiredesignz[/eluser]
I have posted an advanced version of the callbacks into models extension to the wiki. Just for you Daeli. Wink

You must pass the calling object to the Validation class ie: $this->validation->run($this);

This will make Module Models visible to Validation.

[eluser]tomcode[/eluser]
Hopefully I've found now the right thread, sorry having moved up the old one.

I've now successfully converted my app to fit into modular extensions. What a relief to have well ranged functionality. Thanks for this smart, small yet powerful tool.

My question:

Is there a way to declare application-wide (cross -module) variables ?

Since now I worked with a file 'libraries/MY_Controller.php' which was loaded automatically. I then extended my controllers not to the Controller class but to the Commons class. Thus I had a set of base data (and functions) everywhere available. But now this seems no longer possible. MY_Controller is no longer loaded, and even when I put the functionality into the Default_controller, the module controllers ignore whatever happens in the Default_controller.

Code:
libraries/MY_Controller.php:
<?
class Commons extends Controller {

    function Commons()
    {
        parent::Controller();
        
        // base data
        $this->config->load('application');
        $data = $this->config->item('application');
        $data['base_url'] = $this->config->item('base_url');
        $data['charset'] = $this->config->item('charset');
        
        $this->_set_class_vars($data);
    }
    function _set_class_vars($data)
    {
        foreach($data as $key => $value)
        {
            $this->$key = $value;
        }
        $this->load->vars($data);
    }
}
?>

a controller file
<?
class a_controller extends Commons
{
     function index()
     {
     // controller code
     }
}
?>

[eluser]wiredesignz[/eluser]
Class definitions must be so, otherwise it will not load automatically:
Code:
//MY_Controller class
class MY_Controller extends Controller

//A_Controller class
class A_Controller extends MY_Controller

Any other definition for a base controller must be a include:
Code:
//Commons class
class Commons extends Controller

//A_Controller class
include APPPATH."controllers/commons.php";
class A_Controller extends Commons

[eluser]tomcode[/eluser]
small bug notice (if not already changed):

use of .php instead of constant .EXT

file modules_helper.php
* @version: 4.0.26 © Wiredesignz 2008-03-25

line 24

is :
Code:
require_once APPPATH.'libraries/modular_extensions.php';

should be :
Code:
require_once APPPATH.'libraries/modular_extensions' .EXT;




Theme © iAndrew 2016 - Forum software by © MyBB