I'm porting my first mod from OSC, and i'm trying to work through some code changes that the mod makes to the shopping_cart.php file in OSC. Having done some digging, i've found that zen cart uses two files to create the shopping_cart output. modules\pages\shopping_cart\header_php.php and templates\tpl_shopping_cart_default.php.
The issue i have is that i don't want to put sql queries in the tpl file, as it appears they belong in the header_php file, but if i put them in there, then i can't get any output from the variables. Am i supposed to be collecting all the information into an array that is passed to the tpl_ file, or is it called in another way?

Hope that's clear enough.

Thanks in advance for any advice

Steve