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

Add extra field to Featured Products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-18-2008, 05:16 PM
 
ballyhero ballyhero is offline
 

Newbie
  
Join Date: Jan 2008
Posts: 6
 

Default 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
__________________
X cart Gold - Version 4.1.9
Reply With Quote
  #2  
Old 02-19-2008, 01:26 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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.
Reply With Quote
  #3  
Old 02-19-2008, 01:33 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,052
 

Default Re: Add extra field to Featured Products

Have you thought about using the Manufacturers module for Authors?
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #4  
Old 02-19-2008, 12:38 PM
 
ballyhero ballyhero is offline
 

Newbie
  
Join Date: Jan 2008
Posts: 6
 

Default Re: Add extra field to Featured Products

Manufacturers..... interesting. I shall look into it. It seems extra fields are very limited in their flexibility
__________________
X cart Gold - Version 4.1.9
Reply With Quote
  #5  
Old 02-19-2008, 12:39 PM
 
ballyhero ballyhero is offline
 

Newbie
  
Join Date: Jan 2008
Posts: 6
 

Default 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!
__________________
X cart Gold - Version 4.1.9
Reply With Quote
  #6  
Old 02-20-2008, 01:08 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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.
Reply With Quote
  #7  
Old 02-20-2008, 12:22 PM
 
ballyhero ballyhero is offline
 

Newbie
  
Join Date: Jan 2008
Posts: 6
 

Default 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.
__________________
X cart Gold - Version 4.1.9
Reply With Quote
  #8  
Old 02-21-2008, 12:08 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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!
Reply With Quote
  #9  
Old 02-21-2008, 05:02 AM
 
longhorn180 longhorn180 is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Richmond, Virginia
Posts: 187
 

Default 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.
__________________
4.1.9 (Linux) Live Store
www.thecrackedbook.com
Find used books and out of print books.
Reply With Quote
  #10  
Old 02-21-2008, 08:01 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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.
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 05:18 PM.

   

 
X-Cart forums © 2001-2020