Jump to content

include twice in same template?


bloggus

Recommended Posts

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

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 by 4you.software (see edit history)
Link to comment
Share on other sites

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:

obrazek.png.330094d4cf82988b69b41d877c7cdb10.png

Edited by 4you.software (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...