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 - 03-25-2008

[eluser]wiredesignz[/eluser]
Apologies. Only the loader ($this->load) was made to recognise module directories. All other CI objects such as `lang` still try to load files from the application directories as per normal.

I can add a special lang->load function for modules if people feel it necessary. Please let me know.


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]esra[/eluser]
[quote author="wiredesignz" date="1206492735"]Apologies. Only the loader ($this->load) was made to recognise module directories. All other CI objects such as `lang` still try to load files from the application directories as per normal.

I can add a special lang->load function for modules if people feel it necessary. Please let me know.[/quote]

This would make sense. Ideally, modules (or other MVC triads such as partials or widgets) should be loosely coupled to the application. That is, you should be able to add directories or remove directories to add or remove the triads in their entirety. With triad language files stored under application/language/, language files are essentially external dependencies in the sense that they are not stored with their associated triad files and need to be added or removed independently.

There are always going to be exceptions. For example, someone might build separate modules for login, registration, and user. These modules might all share a user_model stored under application/models/, language files stored under application/language/, etc. In those cases, such modules could be considered application core modules in the sense that they have shareable dependencies.


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]wiredesignz[/eluser]
Thanks esra,

$this->load->language loads a module language file no problem, so you keep modularity there.

Its just that $this->lang->load uses application/languages and is a trap for newbies I guess.


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]Daeli[/eluser]
[quote author="Gjoko Pargo" date="1206488704"][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 ?[/quote]

Didn't you forget the "parent::Module();" in the constructor ?


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]Gjoko Pargo[/eluser]
Nope, I haven't as you can see on the previous page. And as you can see on the post from wiredesignz it's a feature from design.

Hay wiredesignz... Yuhuuuu I'm contributing. :cheese:


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]Daeli[/eluser]
Oh sure you are right - didn't see it ><


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]Gjoko Pargo[/eluser]
I need some further help. As you can see from that big post on the previous page I've made the following code structure:

Code:
/system/application/controllers/container.php
This file is the base controller which can be accessed directly via:
http://sitename/container and that one then calls the following partial controller:
Code:
/system/application/modules/komintenti/controllers/komintent.php

On the other hand the partial controller contains calls such as index() and other methods which are connected with the next partial model:
Code:
/system/application/modules/komintenti/models/komintent_work.php

This works great if I want to get records from some table in the database. But now it's time for me to update this CRUD model with basic create/update and delete.

So in my partial view, I've created the links in the following manner:
Code:
http://sitename/container/add

Then I've created an add() method in my container controller which should run the partial controller and transfer the "add" action so the partial controller would know which method to execute.
But it's not working. If I do
Code:
$data["content"]=modules::run(komintent/add)
CI is assuming that I am calling the following URL:
Code:
http://sitename/komintent/controllers/add.php
instead of executing the add() method.
And at this point, I get a 404.

What should I do?


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]wiredesignz[/eluser]
modules::run works this way (module, data, method)
Code:
$data["content"] = modules::run('komintent', $data, 'add');



Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]Gjoko Pargo[/eluser]
[quote author="wiredesignz" date="1206499814"]modules::run works this way (module, data, method)
Code:
$data["content"] = modules::run('komintent', $data, 'add');
[/quote]

Cool! Thanks wiredesignz. I have one more question. From what I can see in the example above you are transferring three parameters to the run method: partial controller name, some sort of variable and partial controller action.
I am puzzled with the second one. In which real world scenario would you need to transfer a variable to the partial?


Modular Extensions - Version 4.3 - El Forum - 03-25-2008

[eluser]wiredesignz[/eluser]
I pass a theme name to the partial in one application, so the partial knows which template to use.