• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to organize my views? Any library?

#1
[eluser]Mauricio de Abreu Antunes[/eluser]
Hello,
I have troubles organizing my views.

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

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

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

#2
[eluser]porquero[/eluser]
See this post:

http://ellislab.com/forums/viewthread/210756/#978265

Maybe it help you.

#3
[eluser]Mauricio de Abreu Antunes[/eluser]
I found these libs:
http://www.askaboutphp.com/48/codeignite...imply.html
http://maestric.com/doc/php/codeigniter_template

Anyone did use these libs once?

#4
[eluser]porquero[/eluser]
I've used second but I prefer use the solution that I post last.
Is most simple, without addons.

#5
[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?

#6
[eluser]porquero[/eluser]
Well. Is not necessary pass head, footer, etc every time.

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

Code:
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

#7
[eluser]Tominator[/eluser]
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.

Tom

#8
[eluser]meigwilym[/eluser]
I'm not sure if this is what you're asking for, but I use Jamie Rumbelowe's MY_Controller.

https://bitbucket.org/jamierumbelow/code...ontroller/

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

Mei


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.