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)
-   -   Add extra field to Featured Products (https://forum.x-cart.com/showthread.php?t=37674)

ballyhero 02-18-2008 05:16 PM

Add extra field to Featured Products
 
Hi, any ideas on how to add a specific extra field to customer/main/featured.tpl? (I want to add 'Author' next to the product title) The code in customer/main/products.tpl just pulls all extra fields in and is not specific so I cant copy that.
Assistance would be appreciated. Thanks

Yurij 02-19-2008 01:26 AM

Re: Add extra field to Featured Products
 
What will be displayed in the field "Author"?

There are several options for how to do this, through the implementation of "Extra Fields" - not very convenient.

Because by default "Featured products" no show "Extra fileds". Need to change "php" code X-Cart.

pauldodman 02-19-2008 01:33 AM

Re: Add extra field to Featured Products
 
Have you thought about using the Manufacturers module for Authors?

ballyhero 02-19-2008 12:38 PM

Re: Add extra field to Featured Products
 
Manufacturers..... interesting. I shall look into it. It seems extra fields are very limited in their flexibility

ballyhero 02-19-2008 12:39 PM

Re: Add extra field to Featured Products
 
Quote:

Originally Posted by Yurij

Because by default "Featured products" no show "Extra fileds". Need to change "php" code X-Cart.


Yes, it is the code I am after. Too complex to work out for myself as I do not know PHP!

Yurij 02-20-2008 01:08 AM

Re: Add extra field to Featured Products
 
I was not much wrong, the task easier, here is a solution to your problem.

1. Create "Extra fileds" for the author, called "author" (name of the field should not be changed, Default value - Empty).

2. Create a new file "skin1/modules/Extra_Fields/product2.tpl" with the following content:
PHP Code:

{section name=field loop=$products[product].extra_fields}
{if 
$products[product].extra_fields[field].active eq "Y" && $products[product].extra_fields[field].value && $products[product].extra_fields[field].field eq "author"}
<
b>{$products[product].extra_fields[field].field}</b> - 
{
$products[product].extra_fields[field].value}
<
br>
{/if}
{/
section


3.Edit the file "skin1/customer/main/products.tpl"
after lines (for xcart 4.1.9 gold):
PHP Code:

<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_page}{if $featured eq 'Y'}&amp;featured{/if}"><font class="ProductTitle">{$products[product].product}</font></a>
{if 
$config.Appearance.display_productcode_in_list eq "Y" and $products[product].productcode ne ""}
<
br />
{
$lng.lbl_sku}: {$products[product].productcode}
{/if} 


insert next lines:
PHP Code:

<br>
{if 
$active_modules.Extra_Fields ne ""}
{include 
file="modules/Extra_Fields/product2.tpl"}
{/if} 


4. Happy end :)

When the module is active "extra fileds, and the product in the" featured product", and for "extra fileds" defined value "author " - will be displayed.

It also displays the value of field "author" when viewing content category.
If the feature is not required, need to make some changes.

ballyhero 02-20-2008 12:22 PM

Re: Add extra field to Featured Products
 
Thats great! Works prefectly.
If other wants to use this code, note the extra field name in the product2.tpl code is case sensitive.

Yurij 02-21-2008 12:08 AM

Re: Add extra field to Featured Products
 
You can easily modify the code and use to groups of parameters, or that extra fields would appear only in a specific place.

f you do not know how, ask me, try to help!

longhorn180 02-21-2008 05:02 AM

Re: Add extra field to Featured Products
 
If you want the author's name to appear beneath the title for a featured product you can edit customer/main/products_t.tpl and add this code right below the product title
Code:

{if $products[product].extra_fields ne ''}
{foreach from=$products[product].extra_fields item=extra_field}
{if $extra_field.service_name eq "author"}
{if $extra_field.value ne ""}
<b>by: {$extra_field.value}</b><br />
{/if}
{/if}
{/foreach}
{/if}

This works just as well.

Yurij 02-21-2008 08:01 AM

Re: Add extra field to Featured Products
 
Quote:

Originally Posted by longhorn180
If you want the author's name to appear beneath the title for a featured product you can edit customer/main/products_t.tpl and add this code right below the product title
Code:

{if $products[product].extra_fields ne ''}
{foreach from=$products[product].extra_fields item=extra_field}
{if $extra_field.service_name eq "author"}
{if $extra_field.value ne ""}
<b>by: {$extra_field.value}</b><br />
{/if}
{/if}
{/foreach}
{/if}

This works just as well.


"Products_s.tpl" will work only if the following conditions are met:
- it is the customer;
- specified rate (Display products list in multiple columns (1-3));
- Module "Featured Products" is active or not active option "Display only featured products list in multicolumn format. "

If any one condition is not fulfilled, "producst_t.tpl" will not be called.

Consider this.


All times are GMT -8. The time now is 10:32 PM.

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