Welcome Guest, Not a member yet? Register   Sign In
need to load multiple views without stacking..
#1

[eluser]ramabodhi[/eluser]
hey all.. as of right now im using dreamweaver templates to control the content on different areas of my site while mainaining consistency.... i haven't gotton into loading multiple views such as header, body, footer separately..

in the news area i have a sidemenu with different topics/areas such as headline, world, us, etc...
so my issue is, say im at the uri news/view/by_date/recent

and the function view($method = 'default', $style = FALSE) calls different models (which make different query's, looking say by date, or topic, etc)..

from here it loads the view with $data which has the news query results..

the problem arises when i click a different buttun, say im at by_topic/world and the button directs to by_topic/US.. it them makes the query to find news articles tagged with 'US', then loads the same view, just with different data.. and i use the code in the view to handle the data..

how do i do this without the views stacking.. the only solution ive cooked up is to use redirects set to refresh in my view() function which load a SEPARATE function to handle view loading.. it sounds complicated.. id rather be able to use multiple view loads in one function, as the page itself is a cyclic function...

really its probably due to the fact that im going about designing the page all wrong, any advice?
#2

[eluser]Colin Williams[/eluser]
Code:
$data['part_one'] = $this->load->view('one', NULL, TRUE);
$data['part_two'] = $this->load->view('two', NULL, TRUE);

// Now start to output the views
$this->load->view('parts', $data);
#3

[eluser]ramabodhi[/eluser]
edit: sorry colin i dont understand your post, but i did check out the template library..

wow i dont know how i didn't find the templates library before.. Smile

so as i understand... i just take my dreamweaver global template put it in my view file, set it as my CI template, then convert all the content areas to regions.. then on each function call, i edit the region data, and load the template?
#4

[eluser]Colin Williams[/eluser]
Template might be right for your project, but I would suggest you work on understanding the code in my post. There is an amazing user guide available to you.
#5

[eluser]ramabodhi[/eluser]
genius... cant believe i didn't get it..., but for this seciton im actually only using one view file for the whole area - news_view.php...

as i understand, to get this to work the way i want, i need to create a second view file, maybe called shell_view.php. Then each time i load a view in the same function, i instead store the view to $data['whatever'] as a string, then load shell_view.php who's sole purpose is a echo $whatever..

am i on the right track?
#6

[eluser]xwero[/eluser]
the parts view looks in his most basic form as
Code:
<?php echo $part_one.$part_two ?>

Just yesterday i altered the load->vars method to make it easier to load views as partials. With my change you can write
Code:
$this->load->vars(array('view:part_one'=>'one','view:part_two'=>'two'));

$this->load->view('parts');
If the partials require data you add it before the view in the array.
Code:
$this->load->vars(array('var'=>'for part_one','view:part_one'=>'one','view:part_two'=>'two'));
#7

[eluser]ramabodhi[/eluser]
Turns out that was just a fancy way of achieving the same problem.. which is that my webpage is displaying twice, stacked vertically...

once again i'm not using any partials.. i have one view news_view.php for this entire process

Code:
function view( $method, $value = FALSE )
    {
        if( $method = 'by_topic')
        {
            $data['view'] = $this->load->view('news/news_view', NULL, TRUE);
            $data['results'] = $this->news_model->where_topic($value);
            $this->load->view('news/shell_view.php', $data);
        }
        if( $method = 'by_date')
        {
            $data['view'] = $this->load->view('news/news_view', NULL, TRUE);
            $data['results'] = $this->news_model->get_recent($value);
            $this->load->view('news/shell_view', $data);
        }
    }

colin i made the code change the way you displayed, and its still just giving me doubles..

what i effectively need is for whatever part of CI that is stacking views to alternately clear the view space everytime a new one is loaded, then ill be happy and on my way
#8

[eluser]pehaw[/eluser]
Both of your if statements are succeeding because you are using the assignment operator rather than the equals operator.
#9

[eluser]xwero[/eluser]
nice catch pehaw!
#10

[eluser]pehaw[/eluser]
Thanks! We aim to please.




Theme © iAndrew 2016 - Forum software by © MyBB