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

help with if then statment for detailed description

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #21  
Old 01-08-2009, 03:28 PM
 
fotodog13 fotodog13 is offline
 

Senior Member
  
Join Date: Sep 2007
Posts: 126
 

Default Re: help with if then statment for detailed description

I think you are correct in that $c is not defined in the product.tpl
I tried
{if $order_by.order_by gt 4 and $order_by.order_by lt 41}{/if}
to the product.tpl
with
$order_by = func_query_hash("SELECT order_by FROM xcart_categories");

$smarty->assign("order_by", $order_by);

added to the product.php with no luck.
I also tried the above with
$smarty->assign('customer/category', 'category');
include ("customer/main/product.tpl");

added to the product.php with same -no results

I need to take a break from this right now but really appreciate your help. I am going to take another stab at it in a few hours. If I get it figured out I will post it and let you know ,as I think that it would be something a lot of others would like to know how to do
Thanks Again

Scott V
__________________
scott v
x cart version 4.1.8 (Unix)
Reply With Quote
  #22  
Old 01-08-2009, 06:12 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: help with if then statment for detailed description

Hi Scott -

If I understand what you are trying to do correctly, maybe this will help.

In product.tpl, the variable $cat contains the categoryid of the current product, so you could do if-than statements based on the $cat variable.

If you do need the category order_by, you will need to add a query to the product.php file to get it. I think this should work if you add it after you see $cat defined:


Code:
$cat_order_by = func_query_first_cell("select order_by from $sql_tbl[categories] where categoryid = '$cat'"); $smarty->assign("cat_order_by",$cat_order_by);

Then, you can do if-than statements based on $cat_order_by

You can try printing the variables in product.tpl to make sure they are as expected:

PHP Code:
category: {$cat}<br />
parent: {$current_category.parentid}<br />
order_by: {$cat_order_by

I've not done this before - so hopefully you won't find any unintended consequences.

Also - using this tip helps show you what smarty variables are available so that you do not have to guess.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #23  
Old 01-09-2009, 09:34 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: help with if then statment for detailed description

tried it and only got this. still no order_by

category: 249
parent: 0
order_by:
__________________
xcart 5.1.2
Reply With Quote
  #24  
Old 01-09-2009, 09:35 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: help with if then statment for detailed description

I added this to product.php

$cat_order_by = func_query_first_cell("select order_by from $sql_tbl[categories] where categoryid = '$cat'");
$smarty->assign("cat_order_by",$cat_order_by);

I tried it first at the beginning of the file right after $cat was defined with no luck, and then again at the end of the file. Does it matter where the code i placed?
__________________
xcart 5.1.2
Reply With Quote
  #25  
Old 01-09-2009, 09:40 AM
 
fotodog13 fotodog13 is offline
 

Senior Member
  
Join Date: Sep 2007
Posts: 126
 

Default Re: help with if then statment for detailed description

Hi Ashley,
I also tried the same thing this AM and had the same results
__________________
scott v
x cart version 4.1.8 (Unix)
Reply With Quote
  #26  
Old 01-09-2009, 10:04 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: help with if then statment for detailed description

ok I got it working.

I placed this code:
$cat_order_by = func_query_first_cell("select order_by from $sql_tbl[categories] where categoryid = '$cat'");
$smarty->assign("cat_order_by",$cat_order_by);

just below this code:
$main = "product";
$smarty->assign("main",$main);

I now get this

category: 249
parent: 0
order_by: 10
__________________
xcart 5.1.2
Reply With Quote
  #27  
Old 01-09-2009, 12:19 PM
 
fotodog13 fotodog13 is offline
 

Senior Member
  
Join Date: Sep 2007
Posts: 126
 

Default Re: help with if then statment for detailed description

HI Ashley,
What a day I have been running like a chicken with its head cut offI
I put the code in as you have above and get the same response but
it still does not appear to be getting me closer to my goal of having a
button that I made appear only on certain product pages not all of them .

I am seeing the code
category: 249
parent: 0
order_by: 10

showing up on all of the product pages are you seeing something different. AM i missing something?

Thanks

Scott
__________________
scott v
x cart version 4.1.8 (Unix)
Reply With Quote
  #28  
Old 01-09-2009, 12:44 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: help with if then statment for detailed description

will it work for you to use the $cat_order_by variable instead of the $c.order_by variable you were trying to use in your if-than statement?

(remove the variables that are printing the category - they were just to help you understand and check that that is what you are after)
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #29  
Old 01-09-2009, 03:31 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: help with if then statment for detailed description

Hi Scott -

Note that I assumed you had set up the categories for which you wanted the button to appear by setting the POS variable in your administration for the categories. So - you had set up the category POS to be 5-40 for those categories.

So the code above pulls from the database what that category POS setting for the current category on each product page. If you are seeing order_by: 10 for every product you check no matter what category, that means the POS variable for those product's category are all set to 10.

If you have different POS variables set for different categories, and you are looking at products from these different categories, and you always see the same settings for {$cat} and {$cat_order_by}, something is still wrong.

I just put all this code in a default XCART to test it, and it appears to work. Maybe you are doing something different with the categories than I see in a default XCART? If you want to send a link for one of your product pages, maybe I will see what is different.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #30  
Old 01-09-2009, 04:14 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: help with if then statment for detailed description

Hi again Scott -

It just struck me that you might be using the POS associated with the products within a category, and not the POS associated with the category itself. (There are a lot of POS settings - so it can get confusing!)

Here is more code for another query that gets that POS for product.tpl. Hopefully this displays the variable that you seek. If you have an individual product in more than one category - the query may need to be adjusted.

In product.php:
Code:
$cat_order_by = func_query_first_cell("select order_by from $sql_tbl[categories] where categoryid = '$cat'"); $smarty->assign("cat_order_by",$cat_order_by); $prod_order_by = func_query_first_cell("select orderby from $sql_tbl[products_categories] where productid = '$productid'"); $smarty->assign("prod_order_by",$prod_order_by);


In product.tpl:
Code:
category: {$cat}<br /> parent: {$current_category.parentid}<br /> order_by: {$cat_order_by}<br /> productid: {$product.productid}<br /> prod_order_by: {$prod_order_by}<br />
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
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 09:13 PM.

   

 
X-Cart forums © 2001-2020