| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
get manufacture in products.php | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
get manufacture in products.php
I'm trying to call the manufacture of a product in products.php so it is accessible in the smarty template customer/main/products.tpl
as {$products[product].manufacture} or something similar. I've dead-ended 2 of my previous attempts to get this to work, has anyone done something similar before, or have any ideas on how to go about it? x-cart 4.0.5 PHP 4.3.9 MySQL 4.0.20-standard Linux I really appreciate any advice Justin
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#2
|
|||||||
|
|||||||
You would have to merge two arrays or create one specifically for manufactures and just use it with the products array. And manufacturers have their own table, so you would need to use the manufactureid from the products table.
Something like this Code:
Example of use in products.tpl Code:
Sorry for the rugged example. This should set you in the right direction at least, if it doesn't work.
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
#3
|
|||||||||
|
|||||||||
I'll preface this by saying I'm no PHP expert, I can usually take care of the task at hand, but this x-cart install is my first venture into SQL, everything I've done before has been PHP with flat text files.
That said, I'm getting a parse error in products.php It looks to me like it's a quotes issue after WHERE manufactureid= My attempts resolve it continue to produce an error too, so perhaps I'm wrong about that. Does anythings stand out to you? Quote:
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#4
|
|||||||
|
|||||||
You're right jds580s,
Here's the fixed query Code:
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
#5
|
|||||||||
|
|||||||||
OK, I've almost got this working, it will correctly display the manufactures name of the first product in a catagory, but none of the subsiquent one.
for anyone else who references this I modified at least one or two things here in products.php Code:
and simplified the products_t.tpl code for my needs Code:
Any ideas on why products after the first don't display? The conditional statement in the .tpl file is correct, when I put some text in there it is "true" for all the products that have a manufacture set, it's just the $manufacturers[product].manufacturer that is only working on the first product. Thanks!
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#6
|
|||||||
|
|||||||
I thought that may happen..
Try adding a new section loop for the $manufacturers array. Code:
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
#7
|
|||||||||
|
|||||||||
Ok, closer still... now it displays the manufacture for all the items that have the same manuf as the last item in the list.
this code also displays the manufacture id number "manid" to help me identify what id is with what product Code:
you can see what this looks like http://www.yarnsmith.co.uk/xcart/home.php?cat=3 the first item's manufacture is Katia manid=6
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#8
|
|||||||
|
|||||||
Ok, I just checked the method I use since I'm actually doing something similar - not with manufacturers but the idea is exactly same. Do away with everything else and try this...
Make a new function in func.php Code:
In products.php Code:
In products.tpl just use Code:
That should work. If not, I'll resign and bake donuts from now on
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
#9
|
|||||||||
|
|||||||||
This seems a little more streamlined, and puts a manufacture at the top of each product... but it looks like the first product is manufacture1 second product is manufacture2 and so on.
http://www.yarnsmith.co.uk/xcart/home.php?cat=3 see example looks like instead of checking the manufacture ID against the name it is taking the number of the foreach loop that it is on.
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#10
|
|||||||
|
|||||||
Ok, then in the template add the if statement
Code:
should solve the problem...
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
|
|||
X-Cart forums © 2001-2020
|