Codeigniter 2.1.3 HMVC templates from /public/themes - codeigniter

I'm using codeigniter 2.1.3 with wiredesignz HMVC, I was wondering how would I get templates from the public folder rather than the modules/module/views?
example structure
application/projects/projectname/ciappstructure
application/system/etc/
public/themes/themename/layout
public/themes/themename/pages
public/themes/themename/widgets
public/themes/themename/etc
I would love to use html files and have my template library sort out the tags and placement of widgets or modules, all modules and theme data being pulled from the DB
like:
$homepage = $this->load->view(FCPATH.'themes/$theme/pages/homepage.html', $data, TRUE);
Oh and another quick question, I'm new to HMVC, could I call modules::run('module/method', $params, $...); from a template library (/application/projects/project/libraries/template.php) ?
I've tried a few things but I can't seem to get anything working, any ideas are much appreciated! Thanks in advance

First, the $this->load->view() load views with .php extension not .html files, Second, this method only load the views on views/ folder.
Therefore, your need config first your modules folder in application/config.php file. Place this on the ends of file.
$config['modules_locations'] = array(
APPPATH . 'modules/' => '../modules/'
);
Next, create your first module with views as sub-folder, and create your view file with .php as extension.
- modules/
--- my_module/
------ views/
--------- my_view.php
Next, in your controller, load the view with the ubication of your module.
$this->load->view('my_module/my_view');
This must run, you can try and read more about the documentation.
Hope this help you!

Related

Move Codeigniter's Model, View and controller folders outside Application

I would like to change/move the Model, View and Controllers folder from application folder and want them to be keep support in a new folder called app. Can someone please give me a solution which would work on CI-3*
application/
library
config
helpers
core
......
app/
model
views
controllers
index.php look for $application_folder and modify this.
You can move views separately using the $view_folder variable.
However, without changing the way the core of CI works you'd have to keep models/controllers inside of application.

Codeigniter working directory inside another working directory

Hi I am working on codeigniter for a while now and have met with an issue.
I use "localhost/controller/function" which is how codeigniter works.
Where controller classes are in controller folder in application.
I have a new codeigniter setup in root folder names "big" with its own controller, view, models etc. How can I run files in "big" like I do for my the original application.
I tried "localhost/big/controller/function", which obviously didn't work.
Please help, I am completely new with codeigniter.
just go to index.php of your application (big)
change/add line:
$application_folder = "applications/big";

Laravel 4 - Accessing Folders

I am new to Laravel 4, and I come from a Zend Framework background. I'd like to create a folder app/forms and keep all my forms there. How can I refer to the form in the controller and within the view.blade files?
By default, the root of the view files folder is app/views so if you create a folder in views like app/views/forms then you may refer the form by it's name from a controller like:
$form = View::make('forms.formfile');
Here, formfile is the name of the file that contains the form and it could be formfile.blade.php and to refer/include the form file from a view you may use #include:
// In a blade view file
#include('forms.form1')
Assume that, form1 is a blade view inside the forms folder and saved as form1.blade.php, you may also use sub-folders inside the forms folder, for example in views/forms/user folder you may keep a view named index.blade.php and use it like:
// From a controller
$userForm = View::make('forms/user/index');
From a view file: (folders are separated by .)
#include('forms.user.index') // file: app/views/forms/user/index.blade.php
You can also nest views in the controller, check the manual for more.
From the standpoint of Laravel, HTML forms (and all presentation related things ) belongs to app/views/ folder. Exceptions are package specific views. For example some commands has their own stubs and views and they are usually stored inside package.
Laravel is very flexibile, and you can move things around and create new folders and namespaces. You just have to tell composer that you are changing Laravel default structure, and dumpautoload. That is if you only want to create new folder with internal reference. If you want something with more scope and visibility you'll have to bind that to container, so that will be visible inside whole application.
You are coming from the Zend world, so I can understand that you want to move some of Zend "flavour" to Laravel. Although is it possible, I would really recommend you to take some time and learn how Laravel works. There are some great ideas and design inside. Of course, Zend has its own quality, but hey - this is Laravel :)

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 & Phil Sturgeon's Template Library - Can I put view partials in a theme folder?

I'm using Phil Sturgeon's Template Library in my CI installation. When I try to put view partials' files in a theme folder, they do get called properly, but if I try to echo a $template variable in them, I get an error message saying that $template variable isn't defined. If I place those same view partials in the root views folder, $template is echoed properly.
How can I have view partials inside a theme and pass $template to them at the same time?
I was encountering the same problem. This looks like its a problem with some fancy hacks Phil had to use for compatibility with Modular Extensions.
If you're not using a parser, simply turn off parser_enabled in the template config file. Its the first option. Then it'll work.
If you're using a parser, you'll have to dig into the library. The problem is in the _load_view function, check lines 725-728. Something needs to be done here to get the variables to the parsed template.

Resources