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)
-   -   Extra fields outside of product.tpl (https://forum.x-cart.com/showthread.php?t=62943)

tqualizerman 03-13-2012 05:34 AM

Extra fields outside of product.tpl
 
Hi,

I'm wanting to be able to use extra fields outside of product.tpl (say in a category listing) - unfortunately calling {include file="modules/Extra_Fields/product.tpl"} doesn't seem to do the trick. Can anyone give me some advice about what the other part of the trick to this would be?

balinor 03-13-2012 05:48 AM

Re: Extra fields outside of product.tpl
 
Lots of posts about how to do this - depends on your version. Your sig says 4.1, but you are in the 4.4 forum.

Start here:

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

cflsystems 03-13-2012 07:21 AM

Re: Extra fields outside of product.tpl
 
Extra fields on product details page is a separate array, on products list page is part of the product array. So calling extra field template directly won't work. Try passing to it extra fields array

{include file="modules/Extra_Fields/product.tpl" extra_fields=$product.extra_fields}

check with the debug window the variable name is correct

tqualizerman 03-13-2012 07:47 AM

Re: Extra fields outside of product.tpl
 
Thanks to both of you for your input on this.

cflsystems - do you expect that code should work on *any* page in the site? I'm trying to get this to work on the BCSE quick order module, but I'm wondering if the variable $product is something that is always available regardless of module, or if i would have to explicitly make it available? I have noticed their coding uses the variable $p instead of $product, but for some other customizations I was able to use $product (for cart functions.)

I specifically only need to reference a single extra field for my purposes, and I've also tried using {$product.extra_fields[0].field_value} and {$p.extra_fields[0].field_value} but no such luck.

cflsystems 03-13-2012 08:25 AM

Re: Extra fields outside of product.tpl
 
The code will not work on any page of the site of course but should work on products list pages. It all depends what is available on the page.

$products array is on every products list page regardless of what modules are in use. You still need to use the debug console and get the correct variable names from there.

tqualizerman 03-14-2012 08:07 AM

Re: Extra fields outside of product.tpl
 
Aha. Thanks for clearing that up for me.

This is all being done inside an addon module that deals with cart functions and product functions...but it could very well be that it does not include the extra fields as part of its $p array.

Can you point me in the direction, or to one of the .php files where the product array is loaded? I would like to see if I can try and force the extra fields to load.


All times are GMT -8. The time now is 03:51 AM.

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