Welcome Guest, Not a member yet? Register   Sign In
View files with common data
#1

[eluser]Body[/eluser]
Hello.
Sorry for my english and sorry if this question have been asked already - my research was not successfull. Smile

Look, i want to use some block of view-code in many parts of my website.

Imagine for simplify i have this data:
Code:
$this->load->library('RatingCounter');

$content['blogEntries'] = array(
      0 => array(
                 'id' => 5,
                 'title' => 'Some title',
                 'content' => 'Some content',
                 'User' => array (
                                  'id' => 2,
                                  'nickname' => 'body',
                                  'points' => '25'
                           )
           ),
      1 => array(
                 'id' => 6,
                 'title' => 'Some title 2',
                 'content' => 'Some content 2',
                 'User' => array (
                                  'id' => 3,
                                  'nickname' => 'test',
                                  'points' => '13'
                           )
           )
);

$this->load->view('blog_view', $content);

In this view file i have this loop:

Code:
<?php foreach ($blogEntries as $blogEntry): ?>
    <h1>&lt;?=$blogEntry['title']?&gt;></h1>

    &lt;!-- USERINFO: This code i want to use in other views, i need to load it dynamic --&gt;
    Username: &lt;?=$blogEntry['User']['nickname']?&gt;<br />
    Rating: &lt;?php echo $this->ratingcounter->get_rating($blogEntry['User']['points']); ?&gt;
    &lt;!-- /USERINFO --&gt;

    <br /><br />
&lt;?php endforeach; ?&gt;

So, i want to use userinfo-block code in other pages too. How can I use this userinfo-block code in this page and in other pages? Note, that i use $this->ratingcounter->get_rating() function here, so i can't just use helpers.

Thanks for advices.


Messages In This Thread
View files with common data - by El Forum - 09-05-2008, 12:06 AM
View files with common data - by El Forum - 09-05-2008, 01:00 AM
View files with common data - by El Forum - 09-05-2008, 01:10 AM
View files with common data - by El Forum - 09-05-2008, 01:40 AM
View files with common data - by El Forum - 09-05-2008, 01:42 AM
View files with common data - by El Forum - 09-05-2008, 01:47 AM
View files with common data - by El Forum - 09-05-2008, 02:53 AM
View files with common data - by El Forum - 09-05-2008, 02:57 AM
View files with common data - by El Forum - 09-05-2008, 03:11 AM
View files with common data - by El Forum - 09-05-2008, 03:14 AM
View files with common data - by El Forum - 09-05-2008, 06:35 AM
View files with common data - by El Forum - 09-05-2008, 07:18 AM
View files with common data - by El Forum - 09-05-2008, 07:40 AM
View files with common data - by El Forum - 09-05-2008, 08:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB