Welcome Guest, Not a member yet? Register   Sign In
How to organize my views? Any library?

[eluser]Mauricio de Abreu Antunes[/eluser]
I have troubles organizing my views.

My home page (after succeed login) has several modules loaded from other models.
--user_data (main module loaded in home controller)

User notes page has news module too.
--notes_data (main module loaded in notes controller)

How to organize my views for non-repetead code?
Its MVC, i need to organize the right way.

See this post:


Maybe it help you.

[eluser]Mauricio de Abreu Antunes[/eluser]
I found these libs:

Anyone did use these libs once?

I've used second but I prefer use the solution that I post last.
Is most simple, without addons.

[eluser]Mauricio de Abreu Antunes[/eluser]
Ok, i got your point.
You mean i need pass an array data to my view (master), loading other views (head, footer, news module, notes module) in my master view. Right?

Well. Is not necessary pass head, footer, etc every time.

You can load repeatable view in main template, something like:

php + html
<?php $this->load->view('header'); ?>
php + html
<?php $this->load->view($view); ?>
php + html
<?php $this->load->view('sidebar'); ?>
php + html
<?php $this->load->view('footer'); ?>
php + html

And only pass view used for controller.

You can find more explanation in my blog: porquero.blogspot

Check COMPER Template Parser (http://parser.comper.sk).
I think you would love two of its features: Appends and Includes.

Every (PHP) module might create it's own data and passes information to parser. After that you can create some master templates and include all necessary parts (templates).

Everything is of course super simple.


I'm not sure if this is what you're asking for, but I use Jamie Rumbelowe's MY_Controller.


This allows easy management of views in a views/{class}/{method} directory structure, as well as a host of other nifty features.


Theme © iAndrew 2016 - Forum software by © MyBB