X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Product Tabs Display (https://forum.x-cart.com/showthread.php?t=57376)

Fascinations 01-05-2011 08:22 AM

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'
    );
}


balinor 01-05-2011 08:27 AM

Re: Product Tabs Display
 
Try this:

http://forum.x-cart.com/showthread.php?t=55180

Fascinations 01-05-2011 08:35 AM

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 *}


Sunray Sales 01-06-2011 05:05 AM

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.

Fascinations 01-06-2011 06:21 AM

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'
    );
}


joncampbell 01-06-2011 07:34 AM

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


All times are GMT -8. The time now is 03:48 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.