feof84 Posted September 28, 2012 Share Posted September 28, 2012 hi, a member of this forum has helped me to write a tpl file, but now I have a problem. In the tpl file I get the image id but the value is always empty. <?php global $smarty; include('../../config/config.inc.php'); include('../../header.php'); $product_list = Product::getProducts($cookie->id_lang, 0,0, 'id_product', 'ASC', 60, true); $smarty->assign('products', $product_list ); $smarty->display(dirname(__FILE__).'/mymodule_page.tpl'); in file tpl: <img src="{$link->getImageLink($product->link_rewrite, $product->id_image, 'home')}" $product->id_image is empty. help me, please! Link to comment Share on other sites More sharing options...
CartExpert.net Posted September 28, 2012 Share Posted September 28, 2012 hi, a member of this forum has helped me to write a tpl file, but now I have a problem. In the tpl file I get the image id but the value is always empty. <?php global $smarty; include('../../config/config.inc.php'); include('../../header.php'); $product_list = Product::getProducts($cookie->id_lang, 0,0, 'id_product', 'ASC', 60, true); $smarty->assign('products', $product_list ); $smarty->display(dirname(__FILE__).'/mymodule_page.tpl'); in file tpl: <img src="{$link->getImageLink($product->link_rewrite, $product->id_image, 'home')}" $product->id_image is empty. help me, please! Hi. The function returns an array. The code you are using in the TPL file applies for objects. Also, the SQL query in the function does not retrieve image information. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
feof84 Posted September 28, 2012 Author Share Posted September 28, 2012 you're right, then I must call id_image differently in the tpl file? how? thank you Link to comment Share on other sites More sharing options...
feof84 Posted September 28, 2012 Author Share Posted September 28, 2012 for the same reason why I return an id wrong <h5> <a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}"> Link to comment Share on other sites More sharing options...
CartExpert.net Posted September 28, 2012 Share Posted September 28, 2012 for the same reason why I return an id wrong <h5> <a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}"> Please explain 'for the same reason why I return an id wrong'. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
feof84 Posted September 28, 2012 Author Share Posted September 28, 2012 in file php: $product_list = Product::getProducts($cookie->id_lang, 0,0, 'id_product', 'ASC', 60, true); $smarty->assign('products', $product_list ); in file tpl: <h5><a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}"> the link of the product: http://127.0.0.1/mytshirt/modules/mymodule/mymodule_page.php if instead use <a href="{$link->getProductLink($produtct.id_product)}" the link is corret. I still can not see the image of the product 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted September 28, 2012 Share Posted September 28, 2012 in file php: $product_list = Product::getProducts($cookie->id_lang, 0,0, 'id_product', 'ASC', 60, true); $smarty->assign('products', $product_list ); in file tpl: <h5><a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}"> the link of the product: http://127.0.0.1/myt...module_page.php if instead use <a href="{$link->getProductLink($produtct.id_product)}" the link is corret. I still can not see the image of the product Hi. You mean the product and image links are not correct? Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
feof84 Posted September 29, 2012 Author Share Posted September 29, 2012 yes exactly. you tell me I'm wrong because I use arrays instead of objects. how should I do? Link to comment Share on other sites More sharing options...
math_php Posted September 30, 2012 Share Posted September 30, 2012 Hi Feof84 As Cartexpert wrote, in tpl you can refer to an Object : {$produtct.id_product} Or an Array : {$produtct.['id_product']} also http://127.0.0.1/myt...module_page.php Refer to a local ip on your computer, which is unreachable through web. You are near the solution, go on. Regards Link to comment Share on other sites More sharing options...
CartExpert.net Posted October 1, 2012 Share Posted October 1, 2012 yes exactly. you tell me I'm wrong because I use arrays instead of objects. how should I do? Hi. This is incorrect: <a href="{$link->getProductLink($produtct.id_product)}" You misspelled '$produtct'. The HTML / Smarty code for the image is: {$link->getImageLink($product.link_rewrite, $product.id_image, 'home')} Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now