X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Working with Twig File (https://forum.x-cart.com/showthread.php?t=76020)

Soptareanu Alex 02-23-2018 02:41 AM

Working with Twig File
 
1 Attachment(s)
I make a module that put some new info on products in the cart. But i need my view class to point from my custom skin and overriede the original shopping_cart/parts/item.info.twig .

This is the original shopping_cart/parts/item.info.twig :
{##
# Shopping cart item : info
#
# @ListChild (list="cart.item", weight="30")
#}

<td class="item-info">
{{ widget_list('cart.item.info', item=this.item) }}
</td>

And this is my custom skin
{##
# Shopping cart item : info
#
# @ListChild (list="cart.item", weight="30")
#}

<td class="item-info">
{{ widget_list('cart.item.info', item=this.item) }}
{% if this.getDataLivrare() is not null %}
<span> Produsul poate fi livrat cel mai devreme la data de <b> {{ this.getDataLivrare() }} </b> </span>
{% endif %}
</td>

The final result must show like in the picture. What should i change in my view class in order to render data from my custom twig ?

cflsystems 02-23-2018 06:14 AM

Re: Working with Twig File
 
Use the moveTemplatesInLists() function in Main.php to remove the original template

qualiteam 02-25-2018 11:23 PM

Re: Working with Twig File
 
Please check this article:
https://devs.x-cart.com/getting_started/how-to-apply-design-changes.html

Sometimes you can decorate an existing view class and make its getDefaultTemplate() method to return the path to your custom template file instead of the original one.

But in this case the template is inserted with the help of @ListChild directive, so you should either a) add a new template to the list and remove the existing one in Main::moveTemplatesInLists(); or b) use Main::getSkins() to register a new theme directory and make templates from there overlap original ones (in this case you don't need the @ListChild directive in your custom files, otherwise templates will duplicate themselves on the page).

Soptareanu Alex 02-26-2018 04:16 AM

Re: Working with Twig File
 
Yes ! It works using Main::moveTemplatesInLists() !


All times are GMT -8. The time now is 12:20 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.