| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
How to Display Product Attributes in a New Tab | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
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 |
|||||||||
#2
|
|||||||||
|
|||||||||
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 |
|||||||||
#3
|
|||||||||
|
|||||||||
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 |
|||||||||
#4
|
|||||||||
|
|||||||||
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. |
|||||||||
|
#5
|
|||||||||
|
|||||||||
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 |
|||||||||
#6
|
|||||||||
|
|||||||||
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 |
|||||||||
#7
|
|||||||||
|
|||||||||
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 |
|||||||||
#8
|
|||||||||
|
|||||||||
Re: How to Display Product Attributes in a New Tab
Quote:
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:
"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:
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. |
|||||||||
#9
|
|||||||||
|
|||||||||
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 |
|||||||||
#10
|
|||||||||
|
|||||||||
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:
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:
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
|||
X-Cart forums © 2001-2020
|