Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Working with Twig File

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-23-2018, 02:41 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Working with Twig File

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 ?
Attached Thumbnails
Click image for larger version

Name:	Shoping_Cart.PNG
Views:	76
Size:	62.4 KB
ID:	5105  
__________________
alex
Reply With Quote
  #2  
Old 02-23-2018, 06:14 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,020
 

Default Re: Working with Twig File

Use the moveTemplatesInLists() function in Main.php to remove the original template
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
qualiteam (02-25-2018)
  #3  
Old 02-25-2018, 11:23 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
Soptareanu Alex (02-26-2018)
  #4  
Old 02-26-2018, 04:16 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Re: Working with Twig File

Yes ! It works using Main::moveTemplatesInLists() !
__________________
alex
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:05 PM.

   

 
X-Cart forums © 2001-2020