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

How to Display Product Attributes in a New Tab

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 07-29-2017, 06:57 AM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default How to Display Product Attributes in a New Tab

I have defined a list of up to 15 product attributes for each product (Key Features).

I want to display the list in a new Product Tab (Features).

Can anyone please tell me what approach I should take to display the attributes? Do I need to create PHP code to extract the required attributes from the Attributes Table or can I do this with a For loop in a Twig Script?
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #2  
Old 07-31-2017, 12:37 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: How to Display Product Attributes in a New Tab

The widget that retrieves information for the built-in Specification tab is this one:
\XLite\View\Product\Details\Customer\Attributes

Depending on whether a product has a class, or product-specific attributes, or etc..., this widget is being displayed multiple times with different parameters (see \XLite\View\Product\Details\Customer\Page\APage::g etAttributesWidgets() method).

So, if you want a custom tab that displays a list of particular attributes only, you should create a custom module that:
1. Defines the new tab by decorating \XLite\View\Product\Details\Customer\Page\APage::d efineTabs() method and specifying what "view list" will render the tab contents.
2. Create a widget class that renders the needed attributes like \XLite\View\Product\Details\Customer\Attributes widget does
3. Make this widget appear in the "view list" by adding a @ListChild declaration
__________________
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
  #3  
Old 07-31-2017, 12:51 AM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default Re: How to Display Product Attributes in a New Tab

Thank you Alex

I can see I have a huge learning curve here.

No matter, I like a challenge. I have a couple of questions that will help me get a grip of the issue:

1) Can you point me to any training documentation that will help me understand concepts such as "decorator", "@ListChild" and other OO constructs. I am familiar programming in C++, so understand the principles such as inheritance, methods etc, but I am unclear how XC5 uses those constructs.

2) Do I need to create a Module to achieve what I need, or can I write suitable code and place it in the current Tab contents? I do not plan to distribute the changes.

Many thanks
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #4  
Old 07-31-2017, 01:34 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: How to Display Product Attributes in a New Tab

In X-Cart 5 you can tweak CSS, JS and templates (webmaster mode) from the backend (see under Look & Feel section). However, when it comes to PHP programming, the code should be wrapped into a custom module (even if you won't distribute it). If you edit core and module files, the next upgrade will revert the changes.

@ListChild and "decorate" are terms specific for X-Cart 5, not OOP. There is a portal where you can find documentation on programming for X-Cart 5:
http://devs.x-cart.com/
__________________
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

Last edited by qualiteam : 07-31-2017 at 01:39 AM.
Reply With Quote

The following user thanks qualiteam for this useful post:
johngwms (07-31-2017)
  #5  
Old 07-31-2017, 03:27 AM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default Re: How to Display Product Attributes in a New Tab

Thank you Alex.

Can you please explain how lists work and what they are used for?
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #6  
Old 07-31-2017, 05:12 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: How to Display Product Attributes in a New Tab

The learning curve is way more than huge. It is not only OOP. You need to learn Doctrine too and Twig. And Vue. And MVC....

Not to mention the XC5 model going back and forth between templates and php scripts, the mix in code when one thing runs from js another from script and another in template...

The lists define some logical structure of data output and the order the data is shown.
If you have List A and you call List B from it List B will always show within List A and not show if List A is hidden. The weight determines the order templates show within the list. Weight of 100 will show the template before another one with weight 200.

So for example if you have stock cart with List A and some templates showing in it and you want to add another one somewhere in between you can set your template weight to a number between the ones you want to show it to. The cart rebuilt will modify the end list order.

Lists in XC5 show not only in templates but in PHP scripts too so good luck trying to find some consistency. The new webmaster mode is a big help of course - use it.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 07-31-2017, 01:16 PM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default Re: How to Display Product Attributes in a New Tab

Thanks Steve

The learning curve would be less steep if there were training materials available at different levels, especially a high-level overview of the XC5 architecture

Right now, I am learning with the help of Mike's videos and looking at code. Things are starting to slot into place in my mind. This is not the quickest way to learn and time isn't on my side. I also have an online store to run, marketing etc.

I can see why some store developers want to stay with XC4. I firmly believe that XC5 is the future.
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #8  
Old 08-01-2017, 01:57 AM
  xplorer's Avatar 
xplorer xplorer is offline
 

X-Cart team
  
Join Date: Jul 2004
Posts: 925
 

Default Re: How to Display Product Attributes in a New Tab

Quote:
Originally Posted by johngwms
Can you please explain how lists work and what they are used for?

Think of "view lists" as named placeholders.

For example, in one of your templates you know that there is a place where some information is going to appear, but you can't say upfront what the information is.

So, in your Twig template, you add something like this:
Code:
{{ widget_list('product.details.page.tab.description.file-attachments', product=this.product) }}

"product.details.page.tab.description.file-attachments" is the name of that list.

Later, when you want to make some other template displayed in that place, you add the following code to that template:
Code:
{# @ListChild (list="product.details.page.tab.description", weight="50") #}

The "weight" parameter determines the order in which the list will render templates. The higher the value, the lower the template will be rendered in the HTML code.

This way your custom modules can inject custom HTML code into existing "view lists" without editing core template files where these lists are defined.

Last edited by xplorer : 08-01-2017 at 01:59 AM.
Reply With Quote
  #9  
Old 08-01-2017, 03:07 AM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default Re: How to Display Product Attributes in a New Tab

Thanks Slava

I think I understand what you are saying, but I still don't understand the high-level purpose of Lists. Are they just an array of data? Are they an XC5 construct or part of one of the OOP methodologies used in XC5?
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #10  
Old 08-03-2017, 03:57 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: How to Display Product Attributes in a New Tab

Hi @johngwms,

The high level-purpose of view lists is to allow to extend templates more flexibly.

For instance the main template for displaying product details is:
skins/customer/product/details/page/body.twig

It has a code {{ widget_list('product.details.page') }} instead of something like
Code:
{% include 'other_template.twig' %} {% include 'yet_another_template.twig' %}

If we used the latter approach and some module wanted to put anything into product page, the module would have to completely replace this template and then add its own {% include %}. But what if two modules want to add their own changes to product details page? In this case, only last module changes would be implemented, while other modules' would be disregarded.

Since we use view lists, multiple modules can register their templates in view lists and all these additional templates will be considered when building a page.

Technically, these view lists are lists of templates assigned to a name. And these view lists are stored in xc_view_lists table in DB. When building a page, X-Cart walks through templates and when it finds function {{ widget_list('view_list_name') }}, it pulls all templates and View classes assigned to this view list name and puts them in place of call of {{ widget_list() }}

Hopefully, it all makes more sense now.

Tony


Quote:
Originally Posted by johngwms
Thanks Slava

I think I understand what you are saying, but I still don't understand the high-level purpose of Lists. Are they just an array of data? Are they an XC5 construct or part of one of the OOP methodologies used in XC5?
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following 2 users thank tony_sologubov for this useful post:
johngwms (08-03-2017), qualiteam (08-07-2017)
Reply
   X-Cart forums > X-Cart 5 > Dev 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 08:41 PM.

   

 
X-Cart forums © 2001-2020