CodeIgniter - the right way to create "block" elements on web page
Posted
by kikkoman90
on Stack Overflow
See other posts from Stack Overflow
or by kikkoman90
Published on 2010-04-14T20:14:17Z
Indexed on
2010/04/14
20:23 UTC
Read the original article
Hit count: 184
Hello. I've been searching for a solutions for this problem a while but haven't seen any "valid mvc" solution for this. I hope I can explain my problem clearly enough for you guys.
I need to create a dynamic block of HTML on my website. (eg. a block containing user's latest blog comments).
I have a template view file (a file containing header, content container and a footer) where I need to add some content AND this block element.
The problem is that I don't want to duplicate this block code on every controller. It just feels stupid and I'm sure there's a better way to do this than just duplicating same stuff all over again on all the controller files?
I can add view inside another view just fine, but what bugs me is how to actually generate that dynamic content to this block's view-file. I can't call controller from view file, controller from controller filem or model from view file because what I understand that just isn't the "mvc" way?
Anyone got any tricks or tips for this?
© Stack Overflow or respective owner