Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)

[eluser]Haqqi[/eluser]
After seeing your Template library, it seems that you also use just one folder to store the template, which is in "APPPATH.'themes/' => '../themes/'". What I want, same with the william's template library, is to store themes or template master file in flexible folder, whether in modules or application.

And can you give some examples of layout files? I'm really blank with this.

[eluser]umefarooq[/eluser]
hi with phil template library you have to create themes folder in application, then for layout create layouts folder in your theme where you can have different layout in there

directory will be like this
Code:
application->themes->your_theme->layouts->layout.php file in the layouts

download template.zip file from this post will help you how your layout will be

http://ellislab.com/forums/viewthread/160554/

[eluser]Haqqi[/eluser]
That's not what I mean. I need the themes to be able to be placed in module folder using modular separation. I create backend module and frontend module. In the future, maybe I will create another module to support other user level. So, what I need is placing the layout in modular way. Is it possible?

CMIIW

[eluser]Rolly1971[/eluser]
why would you want the themes to be modular? ie: part of the actual module.

that would create a huge redundancy, and inconsistent layout for all areas both frontend and backend.

by putting the themes inside the modules you add alot of overhead to the application that can be avoided.

the idea of the modular separation is yes mobility of the modules, but to also seemlessly integrate into applications that you use MS with. By allowing the themes to (or forcing the modules to have their or theme) you create a bad design forcing users to develop their theme for use for every single module released for your app.

this is kind overboard don't think?

[eluser]JoostV[/eluser]
Using Modular Separation with MY_Lang in CI 2.0 needs some tweaking.

In CI2, class MY_Lang in core/MY_lang.php is loaded before MY_Loader.

Therefore, every piece of functionality you put into MY_Lang is overwritten by MY_Loader. This is because in MY_Loader there is a class MX_Lang that also extends CI_Lang
Code:
class MX_Lang extends CI_Lang

One way to fix this is to edit MY_Loader, and replace this
Code:
class MX_Lang extends CI_Lang
with
Code:
class MX_Lang extends MY_Lang

But a dynamic solution would be much better. Any suggestions?

[eluser]Bas Vermeulen[/eluser]
Hello all,

First, thanks for this great library!


For my CI application I have a public folder to hold all the images, js files and themes. Themes are located in the public/theme/{theme} folder and contain the css files and theme specific images. I wanted it to be able to contain some views which overrule the views in application/modules/{module}/views. So I wanted it to load the view from the theme folder if it exists, or else the default view in the modules folder. I wanted the theme views to be sorted by module: public/theme/{theme}/views/{module}/

Folder structure:

application
-- views
---- login_form.php
-- modules
---- group
------ controllers
------ models
------ views
-------- profile.php
public
-- theme
---- themeX
------ views
-------- login_form.php
-------- group
---------- profile.php

I did the following to achieve this:

1) In application/config/config.php I set the theme:
Code:
$config['theme'] = 'themeX';

2) In application/core/MY_Controller.php I load the theme from the config file:
Code:
$this->theme = $this->config->item('theme');

3) In application/core/MY_Loader.php I updated the public function view() which starts @ line 195.

Old code
Code:
list($path, $view) = Modules::find($view, $this->_module, 'views/');
$this->_ci_view_path = $path;
return parent::_ci_load(array('_ci_view' => $view, '_ci_vars' => parent::_ci_object_to_array($vars), '_ci_return' => $return));

Updated code (with some comments)
Code:
/**
* Load the requested view from the theme folder
* if theme specific view is available, if not load
* it from modules folder.
*/
if(isset($this->theme) && file_exists(FCPATH . 'public/theme/' . $this->theme . '/views/'. $view . EXT )) {
    /**
     * Define if the requested view is a module or a
     * general view. Module views should contain a slash
     * Make sure to always load your module views with
     * the module name as prefix from your controllers:
     *  
     * Correct:     group/profile
     * Wrong:       profile
     *
     * The wrong example will load the view from the module
     * folder, but will not load the theme specific view!
     */
    $is_module = preg_match("[/]", $view);
    if($is_module) {
        /**
         * The requested view is a module view, load it from
         * the folder public/theme/{theme_name}/views/{module_name}/
         */                
        list($module, $view) = explode('/', $view);
        $this->_ci_view_path = FCPATH . 'public/theme/' . $this->theme . '/views/'. $module . '/';
    } else {
        /**
         * The requested view is a general view, load it from
         * the folder public/theme/{theme_name}/views/
         */  
        $this->_ci_view_path = FCPATH . 'public/theme/' . $this->theme . '/views/';
    }
} else {
    /**
     * There is no theme specific view for this
     * request, load it from the folder
     * application/modules/{module_name}/views/
     */  
    list($path, $view) = Modules::find($view, $this->_module, 'views/');
    $this->_ci_view_path = $path;
}
return parent::_ci_load(array('_ci_view' => $view, '_ci_vars' => parent::_ci_object_to_array($vars), '_ci_return' => $return));


Not sure if anyone likes this way of dealing with themes and views but for those interested I thought it would be nice to share my solution. Feel free to give your thoughts Smile

[eluser]J Maxwell[/eluser]
Like the idea, I'll have a play with it now and see how it goes. Thanks for sharing!

John

[eluser]kakap[/eluser]
hello every one,

I'm newbie in Codeigniter and I love it. I'm interest with Modular Separation Concept. I don't uderstand too much when I read the instruction "how to apply it into Codeigniter".

any one of Ya'll would like to share simple project or script or application that using codeigniter and modular separation ? I'll use it to be learned.

I need sample such simple application (e.g. making guest book with user authentication application or etc.) that using codeigniter+modular separation.

I hope some one would like to share his application here, so the sample application can be used for learning porpouse.


thank you everyone.

[eluser]Bas Vermeulen[/eluser]
Hi kakap, the concept of modular separation isn't very hard. Let me try to explain, hopefully you will understand. You probably learned that CI uses the MVC model: models, views and controllers. These files have there own folder within the application folder:

application
-- controllers
---- guestbook_create.php
---- guestbook_read.php
---- guestbook_update.php
---- user_login.php
---- user_profile.php
---- etc...
-- models
-- views

With the plain version all your controllers would be in your controller folder => big mess if your app is big Smile To connect to a controller you would have the url: domain.tld/{conroller} (domain.tld/guestbook_read)

When you use modular separation you can split your application in modules, each module has his own folders for models, views and controllers. Folder structure looks like:

application
-- modules
---- user
------ controllers
-------- login.php
-------- profile.php
-------- etc....
------ models
------ views
---- guestbook
------ controllers
-------- create.php
-------- read.php
-------- update.php
-------- etc....
------ models
------ views

To connect to a controller you would have the url: domain.tld/{module}/{conroller} (domain.tld/guestbook/read)

Hope this makes it clear? PyroCMS uses Modular Separation, you can download it and check out the code.

Hf Smile

[eluser]kakap[/eluser]
[quote author="Bas Vermeulen" date="1282870941"]Hi kakap, the concept of modular

Hope this makes it clear? PyroCMS uses Modular Separation, you can download it and check out the code.

Hf Smile[/quote]

haha.. yes, I like PyroCMS Smile but It's too complex for me Big Grin

thank you for your explanation Smile




Theme © iAndrew 2016 - Forum software by © MyBB