Page 1 of 1

Load single model

Posted: Tue Mar 29, 2011 9:02 pm
by Fynn
Hey all,

Quick question, I've been searching for this for a few hours now.

How can I load an individual model in the html view? For example, I want to load 'latest products' on a specific place on the homepage.

Right now there is this code:

Code: Select all

  <?php foreach ($modules as $module) { ?>
  <?php echo ${$module['code']}; ?>
  <?php } ?>
But I want something like this:

Code: Select all

  <?php foreach ($modules as $module) { ?>
  <?php echo ${$module['code']['latest']}; ?>
  <?php } ?>
Is this possible? Thanks!

Re: Load single model

Posted: Wed Mar 30, 2011 12:31 am
by Qphoria
First stop saying "model" when you mean "module" as they are 2 different things

Second, you can do this in the controller:

Code: Select all

$this->children[] = 'module/latest';
after the existing entries for $this->children

Then in the home.tpl you can use

Code: Select all

echo $latest; 
where you want it.

Re: Load single model

Posted: Wed Mar 30, 2011 9:46 pm
by Fynn
Thank you very much Qphoria!