I would love to say I wrote this but alas I didn't.
It cost me a whole bunch of support points to get this coded by X-cart and seeing as.....
a) I see this mod/fix asked for quite a bit by newbs like myself
b) This should be a standard feature of X-Cart - not a required mod and
c) I have received lots of invaluable help from peeps here like Balinor, Zaja et al.....
I thought I would share this with the group
--------------
This MOD is for those that want to display extra fields containing HTML anywhere on your site (almost)..
One of the ways I used this mod was to enable small clickable images that linked to audio previews.
1. Create the following file and name it
modifier.extrafield.php then upload it to the
include/templater/plugins directory :
Quote:
<?php
if (!defined('XCART_START')) { header("Location: ../../../"); die("Access denied"); }
function smarty_modifier_extrafield($value, $mode) {
global $config, $sql_tbl;
$return = func_query_first_cell("SELECT value FROM ".$sql_tbl["extra_field_values"]." WHERE productid = $value AND fieldid= $mode");
if ($return)
return $return;
else
return "";
}
?>
|
2. Modify
skin1/customer/main/products.tpl by adding the following wherever you want it to display :
Note : You must replace the following parts of this code with your own field variables....
NEWFIELD -
replace this with the name of the field you wish to display - ie 'Size'
# -
replace this with the field number of the field you wish to display - ie '2'
Quote:
{assign var="NEWFIELD" value=$products[product].productid|extrafield:#} {if $NEWFIELD ne ""}
NEWFIELD: {$NEWFIELD} {/if}
|
3. Modify
skin1/customer/main/products_t.tpl exactly the same way as described in step 2.
4. Open
admin/product_modify.php &
provider/product_modify.php and look for the following :
Quote:
define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_n ew_full_descr","descr","fulldescr","posted_data"," js_code","javascript_code");
|
Replace with :
Quote:
define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_n ew_full_descr","descr","fulldescr","posted_data"," js_code","javascript_code", "efields");
|
Do the same for both files.
5. To make it a bit easier to enter and edit all your lovely HTML code on the Admin backend do the following...
Open
modules/Extra/product_modify.tpl and find :
Quote:
<INPUT type="text" name="efields[{$extra_fields[field].fieldid}]" size="24" value="{if $extra_fields[field].is_value eq 'Y'}{$extra_fields[field].field_value|escape: "html"}{else}{$extra_fields[field].value|escape:"html"}{/if}">
|
Replace with :
Note. Make sure you change the following part of this code with your own field name.
NEWFIELD -
Change this to the name of YOUR field. ie 'Size'
Quote:
{if $extra_fields[field].field eq "NEWFIELD"}
<TEXTAREA name="efields[{$extra_fields[field].fieldid}]" rows="10" cols="45">{if $extra_fields[field].is_value eq 'Y'}{$extra_fields[field].field_value|escape: "html"}{else}{$extra_fields[field].value|escape:"html"}{/if}</TEXTAREA>
{else}
<INPUT type="text" name="efields[{$extra_fields[field].fieldid}]" size="24" value="{if $extra_fields[field].is_value eq 'Y'}{$extra_fields[field].field_value|escape: "html"}{else}{$extra_fields[field].value|escape:"html"}{/if}">
{/if}
|
And thats it
This works a charm and is a doddle to install.
Enjoy,
G