Welcome Guest, Not a member yet? Register   Sign In
avoiding redundancy
#1

[eluser]belbek[/eluser]
suppose in one controller 'shop' I have 3 functions 'item1,2,3' each of them gives to view file information about 3 items: http://localhost/shop/item1,2,3

and I need a block wich will show information about 4th item and it should be placed on every page together with 3 previous items.

how to avoid redundancy and not to place information about 4th item in each of 1-3 functions?
#2

[eluser]Randy Casburn[/eluser]
in the __controller() do..
Code:
$fourthviewdata = array('stuff'=>'my fourth view data');
$data['fourth_item_view']=$this->load->view('fourthitem',$fourthviewdata);

Then in 1,2,3 load your views with fourth

Code:
$this->load->view('firstview',$this->data);

then in your 1,2,3 views do
Code:
<?=$fourth_item_view?>

where you want the block

---

There you have it,

Randy
#3

[eluser]belbek[/eluser]
Thank you very much Randy.
#4

[eluser]Randy Casburn[/eluser]
You are very welcome!




Theme © iAndrew 2016 - Forum software by © MyBB