You are here:  » Input field

Support Forum



Input field

Submitted by henk on Mon, 2008-02-04 19:46 in

Hi

i like to have in feeds_register_step2.php an input field on the description field.

Thx Henk

Submitted by support on Mon, 2008-02-04 19:49

Hi Henk,

Do you mean like on the Category and Brand, where you can choose a field or enter your own text?

Cheers,
David.

Submitted by henk on Mon, 2008-02-04 19:51

yes

Submitted by support on Mon, 2008-02-04 19:53

Hello Henk,

I'm just thinking - if you have the opportunity to register an empty field as the description (with XML feeds, the first field is always empty) would it be easier just to use a "Text After" field and enter the text you want in the filter configuration?

Cheers,
David.

Submitted by henk on Mon, 2008-02-04 20:06

i am planning it on a other field ( state ) but if its a listmenu its ok 1-2-3-4 option ( uhm how ? )
Henk

Submitted by support on Mon, 2008-02-04 20:09

Hi Henk,

It would be easy to convert it to a drop-down after making the changes for it to be a text box. Below i've copied the instructions from this thread but modified to support the extra text field. To support this, for the example field of "state", you would need to add the following fields to your database:

feeds table:
field_state VARCHAR(255)
user_state VARCHAR(255)

products table:
state VARCHAR(255)

Changes required in admin/feeds_register_step2.php:

Approx line 63 (to call the register function with the new field):

<?php
admin_register
($filename,$format,$_POST["merchant"],$_POST["fieldName"], (isset($_POST["fieldDescription"])?$_POST["fieldDescription"]:"")  , (isset($_POST["fieldImageURL"])?$_POST["fieldImageURL"]:"") ,$_POST["fieldBuyURL"],$_POST["fieldPrice"],$_POST["fieldCategory"],$_POST["userCategory"],$_POST["fieldBrand"],$_POST["userBrand"],$_POST["fieldState"],$_POST["userState"]);
?>

Approx line 163 (to create the field on the form):

<?php
  $userStateDefault 
= (isset($_POST["userState"]) ? widget_safe(widget_posted($_POST["userState"])) : "");
  
$prefixHTML "<input type='text' name='userState' value='".$userStateDefault."' />&nbsp;or use field&nbsp;";
  
field("State","fieldState",$prefixHTML);
?>

Changes required in includes/admin.php:

Approx line 3 (to add the new field to the parameter list of the register function):

<?php
function admin_register($filename,$format,$merchant,$fieldName,$fieldDescription,$fieldImageURL,$fieldBuyURL,$fieldPrice,$fieldCategory,$userCategory,$fieldBrand,$userBrand,$fieldState,$userState)
?>

...and then lower down in admin_register() modify the SQL:

<?php
    $sql 
sprintf("INSERT INTO `".$config_databaseTablePrefix."feeds` SET
                    filename='%s',
                    registered='%s',
                    format='%s',
                    merchant='%s',
                    field_name='%s',
                    field_description='%s',
                    field_image_url='%s',
                    field_buy_url='%s',
                    field_price='%s',
                    field_category='%s',
                    user_category='%s',
                    field_brand='%s',
                    user_brand='%s',
                    field_state='%s',
                    user_state='%s'
                    "
,
                    
database_safe($filename),
                    
time(),
                    
database_safe($format),
                    
database_safe(tapestry_normalise(ucwords($merchant),'\.')),
                    
database_safe($fieldName),
                    
database_safe($fieldDescription),
                    
database_safe($fieldImageURL),
                    
database_safe($fieldBuyURL),
                    
database_safe($fieldPrice),
                    
database_safe($fieldCategory),
                    
database_safe(tapestry_normalise($userCategory)),
                    
database_safe($fieldBrand),
                    
database_safe(tapestry_normalise($userBrand)),
                    
database_safe($fieldState),
                    
database_safe(tapestry_normalise($userState))
                    );
?>

And finally within admin__importRecordHandler($record):

<?php
  
/* construct state value if required */
  
if ($admin_importFeed["field_state"])
  {
    
$state $record[$admin_importFeed["field_state"]];
  }
  elseif(
$admin_importFeed["user_state"])
  {
    
$state $admin_importFeed["user_state"];
  }
  else
  {
    
$state "";
  }
  
$sql sprintf("INSERT INTO `".$config_databaseTablePrefix."products` SET
                    merchant='%s',
                    name='%s',
                    description='%s',
                    image_url='%s',
                    buy_url='%s',
                    price='%s',
                    search_name='%s',
                    category='%s',
                    brand='%s',
                    dupe_hash='%s',
                    state='%s'
                    "
,
                    
database_safe($admin_importFeed["merchant"]),
                    
database_safe($record[$admin_importFeed["field_name"]]),
                    
database_safe(isset($record[$admin_importFeed["field_description"]])?$record[$admin_importFeed["field_description"]]:""),
                    
database_safe(isset($record[$admin_importFeed["field_image_url"]])?$record[$admin_importFeed["field_image_url"]]:""),
                    
database_safe($record[$admin_importFeed["field_buy_url"]]),
                    
database_safe($record[$admin_importFeed["field_price"]]),
                    
database_safe($searchName),
                    
database_safe($category),
                    
database_safe($brand),
                    
$dupe_hash,
                    
database_safe($state)
                    );
?>

Hope this gets you close...!

Cheers,
David.

Submitted by henk on Mon, 2008-02-04 20:27

:) THx

HEnk