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

Product Tabs Display

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-05-2011, 08:22 AM
 
Fascinations Fascinations is offline
 

Member
  
Join Date: Dec 2010
Posts: 16
 

Default Product Tabs Display

I have successfully added a "tab" to the product details page tabs for the extra fields. The problem is: the tab is always there, whether it is needed or not, the extra fields will not be used on all products, so I only want to show the tab if the extra fields have values in them.

Example: some products will have dimensions (extra field), on these products, I want the tab labeled "specifications" to appear with the other tabs (send to friend, customer feedback, etc.,).

other product will not have dimensions listed, but may have materials (another extra field) listed instead, in this case I still want to show the "specifications" tab.

but some products will have neither dimensions or materials, in this case I don't want the tab to appear at all.

I added the tab by editing include/product_tabs.php, the code I added is below.

I am assuming I need to add something else to the extra Fields sections to tell it to only display the "Specifications" tab if at least one of the extra fields has a value in it, but I don't know what?

Any ideas anyone?

Code:
if ($active_modules['Extra_Fields']) { $product_tabs[] = array( 'title' => func_get_langvar_by_name('lbl_specifications'), 'tpl' => 'modules/Extra_Fields/product.tpl', 'anchor' => 'specs' ); }
__________________
X-Cart Pro 4.4
Reply With Quote
  #2  
Old 01-05-2011, 08:27 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Product Tabs Display

Try this:

http://forum.x-cart.com/showthread.php?t=55180
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 01-05-2011, 08:35 AM
 
Fascinations Fascinations is offline
 

Member
  
Join Date: Dec 2010
Posts: 16
 

Default Re: Product Tabs Display

Thanks balinor, but it didn't change anything.

I added the following code to the ui_tabs.tpl file and the tab still shows up even if the extra fields are blank.

Code:
{* Extra Fields Tab Content *} {if $active_modules.Extra_Fields} {foreach from=$extra_fields item=v} {if $v.active eq "Y" and $v.field_value} <div id="product-tabs-{$v.field|replace:" ":"-"}"> {$v.field_value} </div> {/if} {/foreach} {/if} {* End Extra Fields Tab Content *}
__________________
X-Cart Pro 4.4
Reply With Quote
  #4  
Old 01-06-2011, 05:05 AM
 
Sunray Sales Sunray Sales is offline
 

Senior Member
  
Join Date: Dec 2010
Posts: 194
 

Default Re: Product Tabs Display

Ok I understand what you want, here's is how I would tackle this issue.

In the product-tabs.tpl you created the new tab called specification, this will be just pseudo code:

1) First check loop through all extra fields for a value.
For each field in extra fields table, check if there is a value (if value ne '')

2) A new boolean variable that will decide to create the tab or not
If value ne '' then showtab (variable - boolean) = False

3) Show tab or not
If showtab = True, use the code to make the tab


Summary:
So basically you will loop through all extra fields and if even one field has a value, this will trigger the showtab variable to equal True. When showtab is equal to true then only the Specifications tab will be shown.

I would set the showtab variable to False before going through the loop and it should only turn to True if an extra field value is not equal to nothing.

I hope this helps, if you need further assistance I can try and code this myself.
__________________
4.4.2
www.sunraysales.com
HandsOnWebHosting
Reply With Quote
  #5  
Old 01-06-2011, 06:21 AM
 
Fascinations Fascinations is offline
 

Member
  
Join Date: Dec 2010
Posts: 16
 

Default Re: Product Tabs Display

Thanks for your reply, but I am a newbie at this x-cart stuff and far from an expert with php coding, so with that being said -- can you give me an exact example of how this would be written out with the code below. With the code the way it is, it displays the "Specifications" tab all the time whether there are any extra fields empty or not.

This is the code in include/product_tabs.php

Code:
if ($active_modules['Extra_Fields']) { $product_tabs[] = array( 'title' => func_get_langvar_by_name('lbl_specifications'), 'tpl' => 'modules/Extra_Fields/product.tpl', 'anchor' => 'specs' ); }
__________________
X-Cart Pro 4.4
Reply With Quote
  #6  
Old 01-06-2011, 07:34 AM
 
joncampbell joncampbell is offline
 

Advanced Member
  
Join Date: Apr 2010
Location: Vancouver, BC
Posts: 60
 

Default Re: Product Tabs Display

It may be simpler(and cheaper if your time is worth something) to just order Dynamic Product Tabs from WebsiteCM as the functionality to only show tabs with content is already programmed into the module as well as a bunch of other features: http://www.websitecm.com/x-cart-mods/dynamic-product-tabs-for-xcart.html
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not 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 12:57 AM.

   

 
X-Cart forums © 2001-2020