Jump to content

foreach products in .tpl


rrgc

Recommended Posts

hi,

 

i don't know here is right topic for this problem and if is wrong i'm sorry.

 

and im sorry for bad type english to:|

 

i write this query:

$sims = array();
	$sql = "SELECT * FROM ps_product_lang WHERE name REGEXP '$query'";

	if ($results = Db::getInstance()->ExecuteS($sql)) {
		foreach ($results as $row) {
			$sims[] = new Product($row['id_product']);
		}		
	}
	
	$smarty->assign(
	array(
		'simkarts' => $sims,
		'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
		'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
	));
	

and for get all values from "$sims" and show to the tpl template, i write this code:

{foreach from=$simkarts item=simkart name=simkarts}	
	<b>{$simkart.name}</b>
{/foreach}

but dosen't show "name"

 

why ?

 

i think i have to write like this for echo name:

<?php  echo $simkart[$i]->name ?>

 

but in tpl cant write php code ... 

 

please help me

Edited by rrgc (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...