Welcome Guest, Not a member yet? Register   Sign In
View Modules in MVC

Continuing my Noob education...

Have a blog module and a tutorial module.
For the sake of argument, I want the modules to appear in 3 ways.
1) A blog page that displays ONLY the blog module.
2) A tutorial page that displays ONLY the tutorial module.
3) An index page that displays the blog module & the tutorial module.

I can take care of 1 & 2 really easy. The _view for each looks something like this BUT in SEPARATE views:
//BLOG VIEW -> blog_view.php
<h2>&lt;?php echo $blog_title;?&gt;</h2>
<p>&lt;?php echo $blog_article;?&gt;</p>

//TUTORIAL VIEW -> tutorial_view.php
<h2>&lt;?php echo $tutorial_title;?&gt;</h2>
<p>&lt;?php echo $tutorial_article;?&gt;</p>

For #3, I can simply copy and paste that in one index_view.php. However, this gets complicated when I add more things such as author, email, date created, comments, etc. It also reuses a ton of code. So how is this normally done?

Before MVC, I would simply have a file named blog.php and tutorial.php. To accomplish #3, I would just php include them both. I assume there is an easy way to do so in MVC but I am struggling with the change in thought.

Any help is appreciated. Thanks.

OK, nevermind.

Views in Codeigniter

Perhaps a little more research would have helped. I understand now that views are exactly what I used to refer to as modules and I also see now how to load multiple views.


Theme © iAndrew 2016 - Forum software by © MyBB