Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
litespeed_wiki:cache:lscps:customization_1_7 [2018/02/05 21:54] Jackson Zhang [Cart and Login Widgets as ESI Blocks] |
litespeed_wiki:cache:lscps:customization_1_7 [2019/09/18 20:06] Lisa Clarke Removed instructions for widgets |
||
---|---|---|---|
Line 3: | Line 3: | ||
PrestaShop v1.7 [[http://developers.prestashop.com/themes/smarty/helpers.html#widgets|introduces]] ''{widget}'' and ''{widget_block}'' elements that can be used in Smarty templates directly. | PrestaShop v1.7 [[http://developers.prestashop.com/themes/smarty/helpers.html#widgets|introduces]] ''{widget}'' and ''{widget_block}'' elements that can be used in Smarty templates directly. | ||
- | To ensure a hole is punched for a widget, you must define it as an ESI block. Currently, this can not be automated. You will have to manually place LSCache hooks to mark the beginning and the end of each ESI block in the template. LSCache relies on these hooks to trigger the ESI injection. | + | To ensure a hole is punched for a widget, you must define it as an ESI block. Currently, this can be automated in widgets, but not in widget blocks. You will have to manually place LSCache hooks to mark the beginning and the end of each ESI block in the template. LSCache relies on these hooks to trigger the ESI injection. |
- | It currently only impacts cart (ps_shoppingcart) and login (ps_customersignin) blocks at the time of this writing. | + | **Note**:The cart (''ps_shoppingcart'') and login (''ps_customersignin'') blocks are the only blocks impacted by the issue as of this writing. |
- | ===== Widgets as ESI Blocks ===== | + | |
- | The Cart (''ps_shoppingcart'') and Login (''ps_customersignin'') blocks already have hooks defined in the default “classic” template so there is no need to change template files for those particular blocks in that particular template. If ''ps_shoppingcart'' and ''ps_customersignin'' are not triggered through hooks, but through ''{widget}'' or ''{widget_block}'', you //will// have to manually update the template file. | + | Both cart and login blocks already have hooks defined in the default “classic” template so there is no need to change template files for those particular blocks in that particular template. However, if ''ps_shoppingcart'' and ''ps_customersignin'' are //not// triggered through hooks or through ''{widget}'', but through ''{widget_block}'', you //will// have to manually update the template file. |
- | + | ||
- | Surround ''{widget name="ps_customersignin"}'' with ESI hooks like so: | + | |
- | + | ||
- | <code> | + | |
- | {hook h="litespeedEsiBegin" m="ps_customersignin" field="widget"} | + | |
- | {widget name="ps_customersignin"} | + | |
- | {hook h="litespeedEsiEnd"} | + | |
- | </code> | + | |
- | + | ||
- | If the widget also includes a hook parameter, you need to include that in ''litespeedEsiBegin'' as well. For example, ''{widget name="module_name" hook="specific_hook"}'' | + | |
- | + | ||
- | will change to | + | |
- | + | ||
- | <code> | + | |
- | {hook h="litespeedEsiBegin" m="module_name" field="widget" hook="specific_hook"} | + | |
- | {widget name="module_name"} | + | |
- | {hook h="litespeedEsiEnd"} | + | |
- | </code> | + | |
===== Widget Blocks as ESI Blocks ===== | ===== Widget Blocks as ESI Blocks ===== | ||
- | For ''{widget_block}'', if there’s any html code, that will need to be put aside into a template file. So this: | + | If there’s any HTML code, it will need to be put aside into a template file. So this: |
<code> | <code> | ||
Line 52: | Line 33: | ||
This allows us to use ESI to punch a hole for this widget and regenerate the content later. | This allows us to use ESI to punch a hole for this widget and regenerate the content later. | ||
- | ===== An Example: Warehouse Theme ===== | + | ===== Example: Warehouse Theme ===== |
Let’s take the “warehouse” template as an example, and say ''header.tpl'' located at ''themes/warehouse/templates/_partials/header.tpl'' uses variant 1. | Let’s take the “warehouse” template as an example, and say ''header.tpl'' located at ''themes/warehouse/templates/_partials/header.tpl'' uses variant 1. | ||
- | ==== Make changes to template ==== | ||
in ''header.tpl'': | in ''header.tpl'': | ||
{if $iqitTheme.h_layout == 1} | {if $iqitTheme.h_layout == 1} | ||
Line 66: | Line 46: | ||
You will need to modify ''_partials/_variants/header-1.tpl''. Make sure you backup your file before doing any changes. | You will need to modify ''_partials/_variants/header-1.tpl''. Make sure you backup your file before doing any changes. | ||
- | vi _partials/_variants/header-1.tpl | + | <code> |
+ | vi _partials/_variants/header-1.tpl | ||
+ | </code> | ||
- | === 1. ps_shoppingcart as widget_block === | + | ==== ps_shoppingcart as widget_block ==== |
Replace the following: | Replace the following: | ||
Line 87: | Line 69: | ||
</code> | </code> | ||
- | === 2. ps_customersignin as widget === | + | ==== ps_customersignin as widget_block ==== |
- | Replace the following: | + | |
- | + | ||
- | <code> | + | |
- | {widget name="ps_customersignin"} | + | |
- | </code> | + | |
- | + | ||
- | with: | + | |
- | <code> | + | |
- | {hook h="litespeedEsiBegin" m="ps_customersignin" field="widget"} | + | |
- | {widget name="ps_customersignin"} | + | |
- | {hook h="litespeedEsiEnd"} | + | |
- | </code> | + | |
- | + | ||
- | === 3. ps_customersignin as widget_block === | + | |
Replace the following: | Replace the following: | ||
<code> | <code> | ||
Line 118: | Line 86: | ||
</code> | </code> | ||
- | ==== Make changes to multi-templates ==== | + | ==== Making Changes to Multiple Templates ==== |
- | Sometime ''header.tpl'' located at ''themes/warehouse/templates/_partials/header.tpl'' may use various variants, such as the following: | + | Sometimes ''header.tpl'', located at ''themes/warehouse/templates/_partials/header.tpl'', may use multiple variants, like so: |
{if $iqitTheme.h_layout == 1} | {if $iqitTheme.h_layout == 1} | ||
Line 137: | Line 105: | ||
{/if} | {/if} | ||
- | In this case, you will need to back up 7 header files and make changes to these templates from ''header-1.tpl'' to ''header-7.tpl'', the same way as shown above. | + | In this case, you will need to back up all seven header files, and make changes to these templates from ''header-1.tpl'' to ''header-7.tpl'', the same way as shown above. |