Welcome Guest, Not a member yet? Register   Sign In
NOOB, using controllers in this template
#1

[eluser]Unknown[/eluser]
Ok i have the library setup according to instructions and it is working.

there is a little quirk

i have a shopping cart controller.
The view file that displays the products uses a variable that has been passed from this cart controller via

$data['products'] = $this->cart_model->retrieve_products(); // Retrieve an array with all products
$this->load->view('index', $data); // Display the page

so it send the var to index.php in the view folder

this is why im getting the error "undefined var" and "invalid arg supplied to foreach"

so in this context how do i use the library or the cart controller to pass the var to the right place

maybe this is so obvious that im over thinking it due to this hamster wheel im on
#2

[eluser]Unknown[/eluser]
for example

in my page controller that runs my template i have

<?php

class Page extends Controller {

function Page()
{
parent::Controller();
}

function index()
{
$this->template->write_view('content', 'main/main');
$this->template->write_view('sidebar', 'cart/cart');
$this->template->write_view('sidebar', 'cart/products');
$this->template->render();
}

}

?>


its the 'cart/products' that pull the var from the "cart" controller.

its being pushed elsewhere (to index) and not to my page (template) controller

Where do i need to push out this var to be used in this template??




Theme © iAndrew 2016 - Forum software by © MyBB