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

Adding Tabs to Home and Subcategory Pages

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-01-2011, 09:49 PM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Default Adding Tabs to Home and Subcategory Pages

I am setting up a new 4.4.3 Gold store. I want to add tabs to my home and subcategory pages (like the tabs for the product pages). I want Featured products and Bestsellers to appear in tabs rather than in the traditional dialog menus. I have figured out the appearance part and it works, but I'm having trouble with the correct conditional to test for whether there are any Featured products.

I have made a new file in the include folder called welcome_tabs.php. It's modeled after the product_tabs.php. For the featured products tab, I have the following code:

Code:
if (!empty($f_products)) { $welcome_tabs[] = array( 'title' => func_get_langvar_by_name('lbl_featured_products'), 'tpl' => 'customer/main/featured.tpl', 'anchor' => 'featured' ); }

However, it does not allow Featured products to display even when I definitely have Featured products selected. If I get rid of the conditional part, I get the desired effect: 2 tabs - one for Featured products and one for Bestsellers. However, if I have no Featured products selected, a tab still appears for Featured products, but has no content. I don't want to be forced to select Featured products for the home page and every single subcategory, and I want my code to cover all possibilities. It seems as if $f_products is not the correct variable to test, but I can't figure out what might be the correct one. I have looked at featured_products.php and $f_products is all I can come up with. I have a feeling, though, that $f_products is only for template use so it is not recognized as a legitimate variable in a PHP file.

Does anyone have any ideas as to how I can get this to work properly? I did clear my X-Cart cache and temp files in case the problem was related to cached data, but it didn't solve the problem.

Thanks,
Jill
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
Reply With Quote
  #2  
Old 09-02-2011, 04:39 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Adding Tabs to Home and Subcategory Pages

The $f_products array is most likely empty all the time. This array is populated only when featured_products.php is called and $f_products is actually the array name assigned to smarty. The code as you have it in the php will never work as expected unless you call before that another script or function to populate that array
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 09-02-2011, 05:49 AM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Default Re: Adding Tabs to Home and Subcategory Pages

I replied to my own post last night (well, very early this morning really), but I must have accidently hit Preview instead of Submit or something because I don't see my reply now. The issue was as I suspected that $f_products is a Smarty variable so it can't be called as is from a PHP file.

I have now replaced $f-products with $smarty->_tpl_vars['f_products'] in my welcome_tabs.php file and everything is working fine. The tab appears with my Featured products when I have Featured products selected, and no tab appears when I deactivate or delete the Featured products.

I call my welcome_tabs.php file - include $xcart_dir . '/include/welcome_tabs.php'; - from home.php after the include './featured_products.php'; line. Then I replaced the following code in welcome.tpl

Code:
{if $active_modules.Bestsellers and $config.Bestsellers.bestsellers_menu ne "Y"} {include file="modules/Bestsellers/bestsellers.tpl"}<br /> {/if} {include file="customer/main/featured.tpl"}

with

Code:
{if $welcome_tabs} {include file="customer/main/ui_tabs.tpl" prefix="welcome-tabs-" mode="inline" tabs=$welcome_tabs} {/if}

I also plan to modify the featured.tpl and bestsellers.tpl templates for appearance.

I haven't looked at it closely yet, but I plan to modify subcategories.tpl as I did welcome.tpl so I can have the tabbed appearance on subcategory pages, too.
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


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 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 03:49 PM.

   

 
X-Cart forums © 2001-2020