Sub-modules in codeiginter HMVC? - codeigniter

I am building a shopping cart system as part of a CodeIgniter 2 site that uses HMVC.
Instead of having one big "cart" module I was hoping I could break up the module into sub modules.
E.g.
/modules/cart
/modules/cart/config
/modules/cart/controllers
/modules/cart/models
/modules/cart/views
/modules/cart/modules
/modules/cart/modules/categories
/modules/cart/modules/categories/config
/modules/cart/modules/categories/controllers
/modules/cart/modules/categories/models
/modules/cart/modules/categories/views
/modules/cart/modules/products
/modules/cart/modules/products/config
/modules/cart/modules/products/controllers
/modules/cart/modules/products/models
/modules/cart/modules/products/views
Is it possible to do this or something similar?

i worked on codeigniter before 4-5 months. As per as i remember in application folder we can make modules.
Under modules package, we can create the package with the name which we required. We may call it as cart.
Under cart, as per i know, we can not create modules under it. But like each and every folder we can create the particular sub folders and this can solve the your problem as well.
Your folder structure will be like as follows
/modules/cart
/modules/cart/config
/modules/cart/controllers
/modules/cart/controllers/categories
/modules/cart/controllers/product
/modules/cart/models
/modules/cart/models/categories
/modules/cart/models/product
/modules/cart/views
/modules/cart/views/categories
/modules/cart/views/product
i may we wrong. On this link https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home described very well.

Related

sitecore Add users and Media folder after create sub site

I have a sitecore 7.0 solution with several sites.
Every time that I add a new site I need to create specific users (author, approver, etc..) and a specific Media Folder to the website.
Question:
Is there any way to make this automatically? I was thinking to play a bit with the pipelines but I'm not sure exactly how to start..
Thank you
I have made a custom command for this which:
asks for a site name (using Context.ClientPage.Start and Context.ClientPage.ClientResponse.Input)
creates a sites structure based on a template-branch
creates media library folders
I did not need users but you can add that as well. The only thing left to do manually is adding the configuration files.
There are many blog posts to find about adding custom commands, like:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/04/Add-Debug-Command-to-Content-Editor-in-the-Sitecore-ASPNET-CMS.aspx
And also branches:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/Getting-to-Know-Sitecore/Posts/2012/10/Page-Editor-Secrets-1-Complex-Content-Creation.aspx

How to add custom code to the 'system' folder of CodeIgniter?

I am looking into building my own CMS / extended framework on top of CodeIgniter, and I was wondering how to structure it to keep code out of the application folder. I noticed that in a typical CI set up, the file structure looks like this:
application/ //code for your application
system/ //CodeIgniter core
index.php
However, in PyroCMS, They have used the following structure:
application/ //code for your application
system/
--cms/ //PyroCMS core
--codeigniter/ //CodeIgniter core.
How do I accomplish a similar result?
To emulate that structure just edit the index.php constants:
APPPATH
BASEPATH
#WebweaverD has provide you a good solution to improve your application usgin HMVC. I will give you another.
How about something like this:
-system/ //CI core
-index.php //manage the front_end requests
-acp.php //manage the back_end requests
-apps/ //applications dir
--back_end/ //only "admin" controllers, libraries, config. No views here
--frond_end/ //only "user" controllers, libraries, config. No views here
--acp/ //views for back_end
--themes/ //views for front_end
All above can be implemented as you want only extending the necessary core files.
The short answer is that everything starts from index.php, this is where core/CodeIgniter.php is included and it is also where application and system paths are set (retrieving values from config).
I think that pyro cms actually sets /system/cms as the application folder, presumably they have written code which looks at the presented application folder for content and processes it.
Another approach is to use wiredesigns modular HMVC:
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
This will allow you to separate your code out into modules. Just have a folder called cms containing all your cms modules and another folder to build your custom content on top.
You set the path to your modules folder in the config so if you wanted your cms code in the system folder you could set the path to your modules folder there and build on top using codeigniter in the standard way, perhaps adding a hook before or after your controller is loaded to call the cms core.
Mine is just a suggestion but you can easy fork pyrocms and build your own cms on it.
PyroCMS will deprecate codeigniter in the next version so you can keep their code and fix it where you need and modify it as you want

How to load a library from Module using codeigniter modular extensions

i need to load a library from my module using Modular Extensions
my structure like this
modules/
modules/categories/library
categories_class.php
modules/categories/controllers/
categories.php
I need to load categories library in categories controller .
any one cane help me?
I see two problems..
Problem 1
According to your question, your categories module is not organized properly. The whole purpose of HMVC is compartmentalizing of code e.x; modules. Given your present question how does that structure allow you to copy your modules folder and paste it into another app? Answer: It doesnt..
Follow the example below
It should be the following from the app root:
/application/
config
modules/
categories/
views
controllers/
categories.php
libraries/
categories_class.php
models
libraries
core
controllers
Problem 2
per the user guide: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
You must prefix the module name in front of anything referenced inside the modules folder.
e.g: $this->load->library('module/library');
or in your case: $this->load->library('categories/categories_class');
I have attempted previously to exclude the modules folder name and have never gotten it to work.
Controllers can be loaded as class variables of other controllers
using $this->load->module(’module/controller’); or simply
$this->load->module(’module’); if the controller name matches the
module name.
Any loaded module controller can then be used like a library, ie:
$this->controller->method(), but it has access to its own models and
libraries independently from the caller.
I have another perspective for this error behavior, that make me spend about 3 hours, actually I am always using combination of Uppercase and Lowercase on my custom libraries on Codeigniter.
For wiredesigz of Codeigniter HMVC, remember the libraries loader behavior as same as CI itself, always use lowercase of your library classes name instead of actual class name (Maybe combination of uppercase and lowercase)

How to design Joomla style plugin in CodeIgniter

First of all, I want to describe my project architecture:
My project uses jqGrid.
Controllers only define the Grid.
Then Models retrieve the Data for the Grid.
Models are used to Add/Edit/Delete Records.
Views are used to show the page.
Consider, I have 10 different kinds of customers for my project. My project is a hosted solution which serves my all 10 customers from a single source. Among them, eight needs the exact same as I created. Only two are different than the common.
For example, imagine that I want to show a product list. As my project is a hosted solution I can't change the menu by which I can change the controller for the said two customers.
To solve the problem, I want to implement plugin system like Joomla.
How can I do that in CodeIgniter?
Edit
I am using CI 1.7.2.
Maybe it will help you:
There is module solution for Codeigniter HMVC module . It gives you way to divide application logic into modules with their own MVC structure (each module will have it's own model\view\controller).
After installing this module into CI you'll be able to call another module from main app's controller (or view or model) like that:
<?php echo modules::run('module/controller/method', $param, $...); ?>
So I think you can use modules functionality provided by this extension to build per customer modules structure based on customers roles.

CodeIgniter Application Within an Existing Site

Our corporate website already is in place written in "long-hand" PHP. Since we plan to rebuild the site some time in 2011, I don't want to recode it in CodeIgniter (MVC) until we begin the redesign.
However, there are some additions we are making now (i.e., a newsroom/rss feed, a jobs post, etc) that I could add to the site as "modules" until the new design is created in CodeIgniter.
My question -- can I place a CI2 "application" in a folder at the root of my existing site and create my modules in CodeIgniter. For example, a stand-alone CI2 site named news would live in a folder at the root and would be called like www.company.com/news?
Thanks in advance for your insight,
Jon
My question -- can I place a CI2
"application" in a folder at the root
of my existing site and create my
modules in CodeIgniter. For example, a
stand-alone CI2 site named news would
live in a folder at the root and would
be called like www.company.com/news?
Yes you can...
anything else? ;)
All joking aside, you could probably stick it into something like /ci/ and use .htaccess to make URL rewriting, and point your sites /news --> /ci/news/etc;
That way you have 1 single CI instance, and you just point links to the instance:
/news => /ci/news/view/
/form => /ci/form/process/1
etc; number of ways to do it.

Resources