example: URL is contained into smarty variable
{$image->url|escape:'htmlall':'UTF-8'}
that is the url field inside the image table. Ok, now in php have the following:
echo "<![CDATA[<img src='...' alt='thumb' />";
how to replace the content into img src to get the url from database as 开发者_StackOverflowcontained into the smarty variable?
EDIT: i must read the URL field from database inside the image table like smarty does, the result file is .php which shows RSS with xml format
echo "\t\t<item>\n";
echo "\t\t\t<title><![CDATA[".$product['name']." - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')." ]]></title>\n";
echo "\t\t\t<pubDate>" . $logged . "</pubDate>\n" ;
after that i need the IMAGE
that would be something like:
assuming that your php code is something like this:
define('_PS_BASE_URL_', 'something');
define('__PS_BASE_URI__', 'something else');
$smarty->assign('image', $image);
the tpl file could be something like this:
<![CDATA[<img src='{Smarty.const._PS_BASE_URL_}{Smarty.const.__PS_BASE_URI__}img/p/{$image.0.id_product}-{$image.0.id_image}-small.jpg' title='{$product.name}' alt='thumb' />
read about constants here. also for the name replace you would need to use some modifier or functions
Edit 2:
you could use this modifier to replace in your text
Edit 3:
in php just do:
echo "<img src='" , htmlentities($image->url, ENT_COMPAT, 'utf-8') , "' />";
精彩评论