| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Custom Product Tabs | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Custom Product Tabs
This question is really more for Tony than anyone else, but please jump in if you know how to do this.
Looking to create a module for X-Cart 5 (running 5.0.12) that will allow for additional tabs on product pages. In particular, right now I have the "Description" and "Specifications" tabs, want to be able to add a "Extended Specs" tab that would be populated with data fed through a product attribute, and a "Where Used" tab that is populated in a similar manner. For my purposes I can hard code the attribute codes into my module, but could see where someone might want to flesh it out further and make it so administrators can create tabs using the admin screen. Thoughts? Tony?
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Custom Product Tabs
Hi Mark!
Thanks for asking! So, let me first clarify what you want to achieve. 1) You want to create a new tab on product page 2) Populate it with some key/value pairs from attributes of this product right? If so, your plan would be like: 1) Create an empty module 2) Add the View/Product/Details/Customer/Page/APage.php script inside your module with the following content: PHP Code:
Of course, you will have to adjust your namespace. If you rebuild the cache after that, it will show you the new tab which will be empty. After that you will be able to create the template in the skins/default/en/module/DEV-ID/MODULE-NAME/ folder with any name, specify the following comments there: Code:
and its content will be displayed in this tab. Please, try this out and let me know if it works for you. Tony. Last edited by tony_sologubov : 04-03-2014 at 09:57 PM. |
|||||||||
|
#3
|
|||||||
|
|||||||
Re: Custom Product Tabs
*** SOLVED see next post ***
Tony, First, thank you for your quick reply. I created my new module (XLite\Module\Alinc\CustomTabs) with the following Main.php: PHP Code:
And then per your directions in XLite\Module\Alinc\CustomTabs\View\Product\Details \Customer\Page made the following APage.php: PHP Code:
That said, when I rebuild the cache I get this error: Code:
The rebuild completes but the blank tabs do not show up. Did I do something wrong?
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#4
|
|||||||
|
|||||||
Re: Custom Product Tabs
I had the wrong namespace in my APage.php file - for anyone else looking to do this, the right namespace in this case is:
PHP Code:
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#5
|
|||||||
|
|||||||
Re: Custom Product Tabs
Ok Tony, stumped again. I made a global attribute (extended_spec) and fed data into it for a product. I want two things to happen:
1. For extended_spec to NOT show up on the standard Specifications tab and 2. To have it show up in the newly created "Extended Specifications" tab. I tried this for my skins/default/modules/Alinc/CustomTabs/extended_spec.tpl: PHP Code:
But all this does is show the same content as the Specifications tab. How do I actually get it to populate? Also, ultimately want "Related Products" to populate into its own tab - how would I do this? Thank you again for all your help! -Mark
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#6
|
|||||||
|
|||||||
Re: Custom Product Tabs
Tony,
Just bumping this, can you respond possibly to my previous post? -Mark
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#7
|
|||||||||
|
|||||||||
Re: Custom Product Tabs
Hi Mark!
I am sorry for my late reply! Just got slammed by work. First of all, this is great that you created the mod and created view lists for both sections: Extended Spec and Where used. You need two more steps in order to complete your work. 1) Create the method that will return only attributes you need. This is how you can do it. Add the following method to your View/Product/Details/Customer/Page/APage.php script: PHP Code:
This method is quite straight-forward. It pulls all attribute widgets and walk through each attribute checking whether this attribute is color. If it is, then it will be put into the output array $return. Of course, you can define your own if() condition in this case. The result of this step is that we have a method for template that will output only needed attributes, not all of them. 2) After the method is ready, you should edit your extended_spec.tpl template and define it like this (for example): Code:
This template takes our method, walks through needed attributes and displays them. Of course, the template implementation may vary depending on your needs. Please, let me know if it makes sense to you. Tony. |
|||||||||
#8
|
|||||||
|
|||||||
Re: Custom Product Tabs
Tony,
Thank you for your guidance on this. Ok, so I got the code working as described - currently I have the three necessary functions in my APage.php - defineTabs, getExtendedSpecAttributes and getWhereUsedAttributes. The latter two functions I call from their respective tab TPL files, and all that works perfectly. It seems to not be the most elegant code, but it does work. I also modified the defineTabs as follows so it only shows tabs if there is content in them: PHP Code:
Again, probably could have been coded more efficiently but it does function. I still have two questions though:
Thanks again Tony! -Mark
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
#9
|
|||||||||
|
|||||||||
Re: Custom Product Tabs
Hi Mark!
Sorry for not responding here for a long time. Happy to hear that you achieved success with this mod! Quote:
Actually, {a.value:h} should be working. Could you please try it one more time and let me know if the problem is still there? Quote:
In this case, you need to add the getAttributesWidgets() function into your View/Product/Details/Customer/Page/APage.php script inside the module and then delete needed attributes in this method. It will be something like this: PHP Code:
and that is it, after that it should be working as you need. |
|||||||||
#10
|
|||||||
|
|||||||
Re: Custom Product Tabs
Tony,
Thanks for getting back to me. Regarding {a.value:h}, it definitely doesn't work. Here is the full code from that tab - (extended_spec.tpl): PHP Code:
Content for that tab is loaded using the function I developed with your assistance, which is in the View\Product\Details\Customer\Page\APage.php: PHP Code:
And no, HTML is definitely not being parsed - did some simple HTML code, it just renders it all as text. Regarding the second piece, can you elaborate as to what I would put into the foreach ($widget->getAttrList() as $attribute) routine? Just to see what it would do, I put that code in, leaving the routine in question empty, it renders the "Description" tab with no attributes now, but it also empties out the code so no other tabs show up at all.
__________________
X-Cart Gold Plus 4.6.5 Mods - WebsiteCM Dynamic Product Tabs, Smack Digital CDSEO Pro, AlteredCart Smart Search, AlteredCart One Page Checkout, Cart Works Power Filter, Firetank Software Feed Manager |
|||||||
|
|||
X-Cart forums © 2001-2020
|