Welcome Guest, Not a member yet? Register   Sign In
2 columns site help
#1

[eluser]UnknownPlayer[/eluser]
Hi,
i wonna make 2 columns website, now i have 1 problem.
Example, i will have controller news, downloads, videos.
Now on each page on right side(second column) will be different.
- news will have top news
- downloads will have top downloads
- videos will have top videos

now, problem is, do i need to use db queries to select top news in view, or i must pass it through $data variable from controller ?
When i worked on core php, i did this with including side.php file where i put all divs and there i get from db all content that i need, and check basename() of page to check which page is current.

Is there any example for something like this ?
#2

[eluser]Bhashkar Yadav[/eluser]
you can load multiple view files into single controller.
#3

[eluser]UnknownPlayer[/eluser]
I use template.
In template i have header, body and footer. :/
#4

[eluser]TheFuzzy0ne[/eluser]
Views can be loaded from within other views. This means that you can pass all your data to a template view, including the name of view to load within it.

Code:
$this->load->view('main_template', array(
    'title' => 'News',
    'data' => $data,
    'content_view' => 'news_view', // The sub-view to load
));

In the view:
Code:
<div>
    <h2>&lt;?php echo $title; ?&gt;</h2>
    <div id="navigation"></div>
    &lt;?php $this->load->view($content_view); ?&gt;
</div>

There are also other ways of doing it, but that's probably the simplest.

EDIT: Added missing closing bracket. Thanks, InsiteFX!
#5

[eluser]Bhashkar Yadav[/eluser]
yes, in any view file you can load other view files also like ....

Code:
$this->load->view('header');
$this->load->view('main_body');
$this->load->view('footer');
#6

[eluser]InsiteFX[/eluser]
@TheFuzzyOne
Code:
$this->load->view('main_template', array(
    'title' => 'News',
    'data' => $data,
    'content_view' => 'news_view', // The sub-view to load
)); // missing closing )




Theme © iAndrew 2016 - Forum software by © MyBB