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

[eluser]wiredesignz[/eluser]
Yes, don't get dizzy though, it's really easy.

Also doing some tests on loading languages myself, I see that the module file loader will first look into the module language directory and then look into application/language for your language file.

[eluser]dfau[/eluser]
I'm having trouble getting callbacks to work using modules. A simple example is to add a callback to a validation check:

Code:
$rules['email'] = 'required|trim|valid_email|callback_email_check';

and setup the relevant method for handling the check. The callback should get triggered but doesn't; I'm guessing because the method_exists() check (in this case) in Validation.php line 781 is checking the wrong class.

Any ideas?

Many thanks,
df

[eluser]wiredesignz[/eluser]
Unfortunately CI validation callback functions are expected to be located in the controller.

I have a MY_Validation extension which allows callbacks into Models or Modules.

EDIT:
It's on the wiki if anyone is interested:
http://codeigniter.com/wiki/MY_Validatio...to_Models/

[eluser]esra[/eluser]
[quote author="Gjoko Pargo" date="1206172219"]Unfortunately, the link site_url().'/language/setlanguage/english' gives me 404.
By now it became obvious to me that I cannot call a partial directly from the URL. But... I am puzzled how to accomplish a call to a partial without putting some special function in each controller which will handle the request. The ultimate goal is 'copy partial dir to new project - call from view - forget it' or am I unrealistic?
Could this be achieved?[/quote]

There is a reply from wiredesignx earlier in this thread about creating a copy of modules_helper and calling it another name (e.g., partials_helper), then changing the class name and path constant (define) to reflect the existance of a separate partials/ directory. I have not tried this myself, but it seems feasible. I believe that both helpers would use the same modular_extensions library. But, you would use the respective helper in your controller for those view fragments stored in the partials/partialname/views directory and those view fragments stored in the modules/modulename/views directory.

For some users, there may be some confusion about the distinction between the view fragments used by a true partial which is really a reusable, loosely coupled entity which could be installed independently and those view fragments used exclusively by a module which reside in the modulename/views directory and are installed along with the module (which is a separate loosely coupled entity).

[eluser]dfau[/eluser]
Thanks wiredesignz, validation callback works with your extension.

Don't know if it's the "proper" way of doing things or not, but I need to have a callback from a library of my own into a module. method_exists() won't work as you stated, but call_user_func() seems to do the job.

Thanks,
df

[eluser]Gjoko Pargo[/eluser]
Hallo everyone. I would appreciate if you could offer me some help. I am trying to load both models and language libraries from partials, but I get errors and it seems that I cannot find my way around with Modular Extensions.
This is what I have.

/system/application/controllers/container.php:
Code:
class Container extends MY_Controller
  {

    function Container()
    {
      parent::MY_Controller();
    }
    
    function index()
    {
      $data["content"] = modules::run('komintent');
      $this->output->append_output($data["content"]);
      $this->load->view('container', $data);  
    }
  }

Then I have a partial in the following directory with the following structure:
Code:
/system/application/modules/komintent/
/system/application/modules/komintent/controllers/komintent.php
/system/application/modules/komintent/language/english/komintent_lang.php
/system/application/modules/komintent/models/komintent.php
/system/application/modules/komintent/views/komintent.php

These are the relevant files.
/system/application/modules/komintent/models/komintent.php:
Code:
class Komintent extends Model
  {
    
    function Komintent()
    {
      parent::Model();
    }
    
    function index()
    {
      die('Please work');
    }
  }



/system/application/modules/komintent/language/english/komintent_lang.php:
Code:
$lang["PageKomintentTitle"] = 'MYSITE :: Customers';
  $lang["PageKomintentContentTitle"] = 'Manage Customers';



/system/application/modules/komintent/controllers/komintent.php:
Code:
class Komintent extends Module
  {

    function Komintent()
    {
      parent::Module();
      //$this->load->model('komintent');
      //$this->lang->load('komintent', $this->session->userdata('language'));
      modules::debug($this);
    }
    
    function index()
    {
      $data["title"] = $this->lang->line("PageKomintentTitle");
      return $this->load->view('komintent', $data);  
    }
  }


If I uncomment the first line in the file above, then I get the following error message in my browser:
Code:
Fatal error: Cannot redeclare class Komintent in
/opt/lampp/htdocs/ml/www/system/application/modules/komintent/models/komintent.php on line 15

If I uncomment the second line in the file above, I get the other message:
Code:
An Error Was Encountered
Unable to load the requested language file: language/komintent_lang.php

Everything else seems to work ok. I can easily return the view partial back to the Container class as long as I don't use any language libraries or models.
Can you please tell me what am I doing wrong? To be honest I am fresh with CI. This is my first project and I've already jumped into ME without ever building a simple CI application.
Any help is appreciated. Thanks.

[eluser]Gjoko Pargo[/eluser]
OK... I've figured out the module problem. It seems that the partial controller class and the partial model class cannot have the same name. I've changed the model class & file name and it's working. Yet... I still cannot find the solution for the "loading language" problem... and this time it's not 5am here. Sad

[eluser]Gjoko Pargo[/eluser]
Darn... It was not:
Code:
$this->lang->load('komintent');
..like in the rest of CI, but it should be:

Code:
$this->load->language('komintent');

Hope this will be helpful to the other newbies out there... :red:

[eluser]Daeli[/eluser]
I personally use

Code:
$this->lang->load('language');

and it works even in modules correctly. Do you have the latest CI version?

[eluser]Gjoko Pargo[/eluser]
[quote author="Daeli" date="1206481201"]I personally use

Code:
$this->lang->load('language');

and it works even in modules correctly. Do you have the latest CI version?[/quote]

As a matter of fact, I do. The latest CI, and the latest ME.
And you can see the code above. Do you have any assumptions about what might be wrong ?




Theme © iAndrew 2016 - Forum software by © MyBB