• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a shared block with data

#1
[eluser]Unknown[/eluser]
I’m kind of new to this framework.

Can I know how do I make a proper shared block that contains pulled data from the database?

For example a “Featured product block” where I can located in different pages?

Product Controller

Code:
public function featured_product_block(){
  $product_array = $this->product_model->get_product();
  $data["products"] = $product_array;
  $this->load->view("blocks/product_block", $data);
}

So do I just call this controller from another controller? Or is there another way to do it?

#2
[eluser]CroNiX[/eluser]
You can't call a controller from a controller. If you need to use something in multiple controllers, you should use a library or a helper.

#3
[eluser]InsiteFX[/eluser]
Or use Modular Extensions

MODULAR EXTENSIONS 5.4

#4
[eluser]CroNiX[/eluser]
Do you know if Wiredesignz is going to port it to CI3, or if it works in CI3? If we don't know that, I wouldn't recommend using it or it would make you have to rewrite a lot of code if/when you do upgrade. Using libraries/helpers is more foolproof as they are actually a part of CI and probably always will be.

#5
[eluser]InsiteFX[/eluser]
From talking with him he told me he would port it to CI 3.0 when it is released.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.