Jump to content

Edit History

ps8modules

ps8modules

You have to give me your sql query to get the pictures.
Writing something in general takes a long time.

Smarty variables are used for TPL templates.

In the module:

$getImages = Db::getInstance()->executeS('SELECT image_name FROM '._DB_PREFIX_.'my_image_table WHERE image_id IN (1,2,3,4)');
$images = array();

foreach ($getImages as $img){
    $images[] = Tools::getHttpHost(true).__PS_BASE_URI__.'modules/ModuleName/views/img/'.$img['image_name'];
}

$this->context->smarty->assign([
	'my_module_images' => $images,		
]);

In TPL:

{if $my_module_images}
  {foreach $my_module_images as $image}
    <img src="{$image}">
  {/foreach}
{/if}

 

ps8modules

ps8modules

You have to give me your sql query to get the pictures.
Writing something in general takes a long time.

Smarty variables are used for TPL templates.

In the module:

$getImages = Db::getInstance()->executeS('SELECT image_name FROM '._DB_PREFIX_.'my_image_table WHERE image_id IN (1,2,3,4)');
$images = array();

foreach ($getImages as $img){
    $images[] = Tools::getHttpHost(true).__PS_BASE_URI__.'modules/ModuleName/views/img/'.$img['image_name'];
}

$this->context->smarty->assign([
	'my_module_images' => $images,		
]);

In TPL:

{if $my_module_images}
  {foreach $my_module_images as $image}
    <img src="$image">
  {/foreach}
{/if}

 

×
×
  • Create New...