Making codeigniter admin to rule them all - codeigniter

I want to make a codeigniter admin/cms to manage all my clients front ends, i want to separate the admin application in two folder, the generic folder, that all other will extend or use, and the client site admin, that i will make for the client needs.
Can it be done?

i recommend the WireDesigns HMVC - https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
This will allow you to make 2 modules Front-End / Admin in each module it follows hte same rules of Controller / Model / View which you can build up each one independently but to work together.
Technically though you could just create 2 folders in your controllers folder called Frontend / Admin, and build your controllers right there.
but if you looking for cleaner ogranization, try the HMVC

Related

How to create a seperate directory for admin controller in cakephp

I am new to cakephp development. I have create user controller to register, login & update own profile in the user table. I can access the user controller with http://local-host/my_project/user/login.
I have also a admin table in database so that admin can login and manage user in my project. I want to create a folder separate folder (ex: admin) in the controller directory so that i can access the controller files using http://local-host/my_project/admin/controller/login & http://local-host/my_project/admin/controller/manage.
You should have a look at 'prefix routing' in the manual, it seems that this is what you're looking for:
http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing
With prefix routing, you'll be able to add, for example, an action admin_overview() to your User controller which is then accessible via the URL /admin/users/overview. The 'admin' prefixed action will not overlap with non-admin actions (e.g. 'overview()'), which will be accessible via the 'regular' URL; /users/overview/
Of course, you can create separate admin controller(s) for this purpose, but you may need to create custom routes. For more advanced options regarding routing, it's worth your time to read the whole chapter (or, even better) read the whole cake cookbook, it's also available as eBook for offline reading;
http://book.cakephp.org/2.0/en/index.html
Another solution is to develop the 'admin' part of your application as a plugin. This will keep your frontend and backend controllers/models/views separated. As a bonus, the backend may can be re-used for other projects as well (depending on its design of course)
http://book.cakephp.org/2.0/en/plugins.html#creating-your-own-plugins

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

codeigniter: admin/cms as separate project or part of the same

So I've built a front-end to a website in Codeigniter, it has public and members areas.
Now it's time to build the backend administration where staff can manage some content: http://mysite.com/admin
At first I was going to just create subfolders within my controllers, models,views and resources folders for 'admin'
I'm wondering if I should just be doing a separate installation of CI for the admin? the layouts are different, the auth is different, sure they will share the same MySQL database but the admin will have different models and controllers
Best approach?
This article by Phil will give you a better idea:
http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

Codeigniter expressionEngine

I just started working with codeigniter and i found it easy to work with. I recently came across expressionEngine and seems like a great add-on for codeigniter. My questions is, after i install expressionEngine, will that change the way i work with codeigniter where code goes in controller and view in the view folder.
Apples and Oranges,
Codeigniter is a framework that allows you to create a Web Application like an admin system. The customer does not add any content or touch anything. You can add CMS functionality to your codeigniter Web Application however in this sense you are actually building your own CMS on top of your Web Application.
ExpressionEngine, built with codeigniter, is a CMS that allows clients to add content without actually giving them access to your HTML - That is not to say that you can't give them access but this would defeat the purpose of a CMS.
Because expressionEngine is built on top of codeigniter it is possible to access it's functionality (I've seen posts on this but haven't tried it yet myself).
I think you would use the two together if you had a Web Application with a Website around it. In this way the client would be able to add content to the website and even some of the Application information areas but you would use Codeigniter to build the Web Application's functionality.
I don't think it would be a waste of a week to get into expressionEngine. LevelUpTuts has some great video tutes on expressionEngine 2 and try Nettuts+ CodeIgniter from Scratch for, suprisingly, codeigniter.
(For those who are new to CMS) The general process of development is:
- Translate your website design to HTML/CMS/jQuery
- Translate your HTML to expresionEngine Templates
- Define your Channels which your clients will add content to
- Embed those Channels into your templates to display that content dynamically
- In administration, assign permissions to who can add content to which channels for your clients
It will start to make sense once you try it.
You can't layer ExpressionEngine on top of CodeIgniter since CodeIgniter is extracted from ExpressionEngine. It's EE all the way, or use CodeIgniter to build your own thing.
ExpressionEngine supports PHP code inside it's templates if that's what your asking.
EE(2.0) is a CMS built on the CI2.0 framework.
If you are familiar with CI you will be able to hack, modify and extend EE with ease, as well as develop your own plugins etc.
You can of course, have an EE installation and a CI installation on the same server, but the two do not interact directly - CI is a framework, EE is a CMS.
Not sure I would call EE an "add-on"...
EE is it's own standalone Content Management System. Generally EE and CI are not meant to be mixed. While EE is built on CI, it is not meant to be extended/changed etc... They (Ellislab) will tell you, If EE doesn't fulfill your requirements, then you need to use CI exclusively.
Plus, a 300$ license is pretty expensive for something that you view as an "add-on".
I would reccomend looking into PyroCMS, which is also a free (beer and speech) CMS built on CI that directly allows for "Module" development which is straight codeigniter development with a few added meta/installation files that would allow you to build the extra functionality you need within the Codeigniter structure.
There are four files for expression engine.
For Example i have module named "Products"
1)mcp.products for admin end or admin control panel just admin controller in pyrocms
2)mod.products front end code is placed here 3)tab.products tabs are here 4)upd.products installation code. There are views in "views" folder and model is in "model" folder in our case "products_model". Just copy your controllers methods and paste them in mcp.products.php on admin side. and copy your controllers methods and paste them in mod.products.php on front end side. in udp file place the table structure.and it will treat as you are in Pyrocms.

Codeigniter HMVC and CMS

I am using Codeigniter with the HMVC Modular extension and have a backend CMS area for managing website content. I am routing the base URL + "admin" (http://localhost/cms/admin) to controller methods with the prefix "admin_".
e.g. function admin_index() {...}
And here is my routing:
$route['admin/([a-zA-Z]+)/(:any)'] = "$1/admin_$2";
$route['^admin/(:any)(/)?'] = "$1/admin_index";
$route['^admin(/)?'] = "dashboard/admin_index";
$route['admin/logout'] = "login/admin_logout";
With the HMVC it is not routing correctly now. Here is what happens:
URL: http://localhost/cms/admin/faqs
Directory: modules/faqs/controllers/faqs - index method
--
here is where it breaks
--
URL: http://localhost/cms/admin/faqs/categories
Directory: modules/faqs/controllers/faqs - categories method (does not exits)
Desired: modules/faqs/controllers/categories - index method
How can I use HMVC while maintaining the "admin" are of the website?
You are making life a bit too tricky by putting frontend and backend functions in the same controllers. Have a look at my article on how to create an admin structure in CodeIgniter.
I'm working on something similar, and implemented a swapping like you did (3rd option) and it worked fine.
I tried to implement a front controller to handle the admin section, and run modules with HMVC modules::run() and buffer the output as I wish, but then I have faced another issue, you will have to change the URI schemes from / to _ or something else, since you wont be able to send module segments as parameter to your controller because CI relies on "/" for it's routing mechanism.
The only way is to emulate the admin section as Phil suggested, but there is another option to still have control over the code implemented by anyone using your CMS.
You could extend CI_Controller (or MX_Controller in case you are using HMVC) and add an Admin_Controller which will handle your logic and control what modules can do.
Have a look at this CodeIgniter Base Classes: Keeping it DRY

Resources