Gata Posted March 4, 2003 Share Posted March 4, 2003 Hi, I am struggling with trying to add some fields to the product description. I have edited some files in admin and I am getting this error message when test- adding a product: Fatal error: Call to undefined function: tep_get_products_author() in /hsphere/local/home/myopic/myopicbookstore.com/admin/categories.php on line 413 Does anyone know where in admin/categories.php I would define the function for tep_get_products_author() and what is the syntax to use? Thanks for any help! Link to comment Share on other sites More sharing options...
Ajeh Posted March 5, 2003 Share Posted March 5, 2003 You can make your own funciton file and put it in /includes/functions and then add an include statement to the end of /includes/functions/general.php Link to comment Share on other sites More sharing options...
Gata Posted March 5, 2003 Author Share Posted March 5, 2003 Thanks for the reply Linda. I did take a look at the function file. I do have a question though. I am trying to add the field here: I just cut and pasted a block of code in admin/categories.php in the same spot as the code for product_name, product_description, price, etc. I am very new to php- and am trying to learn fast as I go- but adding fields is really confusing me! It seems logical that I would add this missing function to the same place as the other fields' information. (Hope this is not too confusing!) The code is below. Under the block for products_name, I just duplicated it and changed it to products_author: <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?> <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?> <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_AUTHOR; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_author[' . $languages[$i]['id'] . ']', (($products_author[$languages[$i]['id']]) ? stripslashes($products_author[$languages[$i]['id']]) : tep_get_products_author($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?> <tr> <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td> <td><table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td> <td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (($products_description[$languages[$i]['id']]) ? stripslashes($products_description[$languages[$i]['id']]) : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> </table></td> </tr> <?php } ?> Link to comment Share on other sites More sharing options...
Ajeh Posted March 6, 2003 Share Posted March 6, 2003 But where have you written the function: tep_get_products_author Does this exist? Or is it just a duplication issue of the existing code? If it does not exist, look in /includes/functions/general.php and take this code: //// // Return a product's name // TABLES: products function tep_get_products_name($product_id, $language = '') { global $languages_id; if (empty($language)) $language = $languages_id; $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $language . "'"); $product = tep_db_fetch_array($product_query); return $product['products_name']; } And make a new function, assuming the products_author is in the products_description: //// // Return a product_author's name // TABLES: products function tep_get_products_author($product_id, $language = '') { global $languages_id; if (empty($language)) $language = $languages_id; $product_query = tep_db_query("select products_author from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $language . "'"); $product = tep_db_fetch_array($product_query); return $product['products_author']; } If in products table, then use this for the function: //// // Return a product_author's name // TABLES: products function tep_get_products_author($product_id) { $product_query = tep_db_query("select products_author from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_author']; } Put that new function either in your own function file and add an include on the general.php or put it in the general.php file. Link to comment Share on other sites More sharing options...
Gata Posted March 6, 2003 Author Share Posted March 6, 2003 Linda, Thanks for your help. It worked perfectly- and I understand now where to look for and add functions. I was looking for the missing function in the wrong file. As always, I learn alot on this board. G'day! Catherine Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.