bloggus Posted September 25, 2022 Share Posted September 25, 2022 Hi, I have to use include twice ina template. Is there a better way, like maybe storing the first output, so it don't have to be generated twice? {block name='product_info'} {include file='catalog/product-info.tpl'} {/block} .. .. .. {block name='product_info'} {include file='catalog/product-info.tpl'} {/block} Can I save the first include somehow and use it again below again? Link to comment Share on other sites More sharing options...
ps8modules Posted September 25, 2022 Share Posted September 25, 2022 (edited) Hi, the best will be to use javascript instead of the second include and copy the content and paste it below. Unfortunately, you did not include the version of Prestashop, the used theme of the template and possibly the content of the file product-info.tpl. Otherwise I would give you the whole code here. Edited September 26, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted September 26, 2022 Share Posted September 26, 2022 (edited) sample: {block name='product_info'} {include file='catalog/product-info.tpl'} {/block} .. .. .. {block name='product_info_copied'} <div id="copied-product-info"></div> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { setTimeout(myCopyContent('{$product.id}'), 500); }); function myCopyContent(product_id) { var content = document.getElementById('product-description-short-'+product_id).innerHTML; /* copy html content */ /* add content to your new div */ document.getElementById('copied-product-info').innerHTML = content; } </script> {/block} result: Edited September 26, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
webprog Posted September 26, 2022 Share Posted September 26, 2022 13 hours ago, bloggus said: Can I save the first include somehow and use it again below again? See: https://www.smarty.net/docsv2/en/language.function.include.tpl Your example will be: {block name='product_info'} {include file='catalog/product-info.tpl' assign=prod_info} {$prod_info nofilter} {/block} .... .... .... {$prod_info nofilter} Link to comment Share on other sites More sharing options...
bloggus Posted September 26, 2022 Author Share Posted September 26, 2022 (edited) 56 minutes ago, webprog said: See: https://www.smarty.net/docsv2/en/language.function.include.tpl Thank you! I tried that before my post, but the result was bad and I see now I forgot the "nofilter"... Edited September 26, 2022 by bloggus (see edit history) 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