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

How to use If condition

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-16-2011, 03:28 PM
 
Mickeyt Mickeyt is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 68
 

Default How to use If condition

HI,

Just have an idea to create a new thread with use of IF condition examples.

Can somebody help me to use If condition to hide a category thumbnails, but only if category name is called for example: LED diodes?

Second question for IF. How to change product template layout for a specific category. For example, IF category is called LED diodes I want to use one column product grid. Else I want to use the default one set up in general settings.

Thank you for your help, and pls, add yours if conditions for interesting cases you have.

Tom
__________________
Tom

X-CART 4.4.1
Reply With Quote
  #2  
Old 01-17-2011, 06:58 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,471
 

Default Re: How to use If condition

Quote:
Originally Posted by Mickeyt
Can somebody help me to use If condition to hide a category thumbnails, but only if category name is called for example: LED diodes?

How are you categories displayed? In a list or multiple columns?

Quote:
Originally Posted by Mickeyt
Second question for IF. How to change product template layout for a specific category. For example, IF category is called LED diodes I want to use one column product grid. Else I want to use the default one set up in general settings.

This is currently not possible within xc, however there's a mod that can help you achieve this. I explain about this here:
http://forum.x-cart.com/showthread.php?t=57369
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #3  
Old 01-17-2011, 11:08 AM
 
Mickeyt Mickeyt is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 68
 

Default Re: How to use If condition

HI I use multiple columns (3) and for products I use 4columns.

Other if statement I want to use is for home page featured products. I want to rename it to New Products, but only at home page. For all other pages I wan to leave it as Featured Products. Any idea?
__________________
Tom

X-CART 4.4.1
Reply With Quote
  #4  
Old 01-19-2011, 03:45 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,471
 

Default Re: How to use If condition

Quote:
Can somebody help me to use If condition to hide a category thumbnails, but only if category name is called for example: LED diodes?

Open up subcategories_t.tpl (located in /skin/common_files/customer/main)

Find the following code (Around line :
Code:
{if $subcategory.is_icon} <a href="home.php?cat={$subcategory.categoryid}"><img src="{get_category_image_url category=$subcategory}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" /></a> {else} <img src="{$ImagesDir}/spacer.gif" alt="" width="1" height="{$subcat_img_height}" /> {/if}

and replace it with the following:

Code:
{if $subcategory.is_icon} {if $subcategory.category NEQ "LED diodes"} <a href="home.php?cat={$subcategory.categoryid}"><img src="{get_category_image_url category=$subcategory}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" /></a> {/if} {else} <img src="{$ImagesDir}/spacer.gif" alt="" width="1" height="{$subcat_img_height}" /> {/if}
So basically, if the current subcategory is not called "LED diodes" then display the image.

Quote:
Other if statement I want to use is for home page featured products. I want to rename it to New Products, but only at home page. For all other pages I wan to leave it as Featured Products. Any idea?

If it's only for the homepage then yes...
The featured products section is driven via customer/main/featured.tpl
If you make a copy of the file and call it something like featured_home.tpl and make the custom changes you want here.

Then amend customer/main/welcome.tpl (Which is the site's frontpage) to include featured_home.tpl instead of featured.tpl.

HTH
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote

The following user thanks chamberinternet for this useful post:
Mickeyt (01-20-2011)
  #5  
Old 01-20-2011, 06:49 AM
 
Mickeyt Mickeyt is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 68
 

Default Re: How to use If condition

Hi HTH,

thanks the first one works only for subcategories, not for root categories. Can you kick me ones more with code for ROOT Categories?

Thank you for Featured products help. That works Perfectly. Is any public list of variables used in xcart?

Sorry for bothering you so much.

Tom
__________________
Tom

X-CART 4.4.1
Reply With Quote
  #6  
Old 01-20-2011, 07:08 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,471
 

Default Re: How to use If condition

Quote:
thanks the first one works only for subcategories, not for root categories. Can you kick me ones more with code for ROOT Categories?
As far as I know root category images are not displayed on any of the default x-cart templates... Unless you've modified them?

Quote:
Thank you for Featured products help. That works Perfectly. Is any public list of variables used in xcart?
Sure, if you enable the debugging console within the administration area then all the smarty variables are displayed for the current page. See http://help.qtmsoft.com/index.php?title=X-Cart:Editing_Skin_Files#Using_Debugging_Console for more info.

Shafiq
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #7  
Old 01-20-2011, 07:15 AM
 
Mickeyt Mickeyt is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 68
 

Default Re: How to use If condition

My Apologize,

what I need is to hide all subcategories images for root category called "LED Diodes".

What's your script doing is not showing subcategory image for subcategory called "LED Diodes" only.

Tom
__________________
Tom

X-CART 4.4.1
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 04:56 AM.

   

 
X-Cart forums © 2001-2020