celia_ccs Posted September 23, 2005 Posted September 23, 2005 (edited) Hi, I'm developping a contribution to create some templates (called mask) to update the content of the homepage. I'm trying to develop the admin page where you can create modify and add new templates. I've used pretty much the same structure as the page categories.php. Everything is working fine except when I go back to editing after the preview. I tried several things, first it was going back but the edited information was not appearing. But now it's not even going back to the editing page. New template : action= new -> action=preview -> action=insert Edit template : action=edit -> acion=preview -> action=update Could you look at the code and tell me what is wrong ? Development files may be downloaded here Thanks, Celia <?php /* ?osCommerce, Open Source E-Commerce Solutions ?http://www.oscommerce.com ?Copyright (c) 2002 osCommerce ?Released under the GNU General Public License ? ?Homepage template admin */ ? require('includes/application_top.php'); require (DIR_WS_FUNCTIONS."globalfunction.php"); //VARIABLES $dir_img=DIR_WS_CATALOG.DIR_WS_IMAGES."homepage/"; // change status ?function tep_set_template_status($template_id, $status) { ? ?if ($status == '1') { ? ? ?return tep_db_query("update " . TABLE_HOME . " set status = '1' where template_id = '" . $template_id . "'"); ? ?} elseif ($status == '0') { ? ? ?return tep_db_query("update " . TABLE_HOME . " set status = '0' where template_id = '" . $template_id . "'"); ? ?} else { ? ? ?return -1; ? ?} ?} ?switch ($HTTP_GET_VARS['action']) { //SETFLAG ? ? ?case 'setflag': ? ? ?tep_set_template_status($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']); ? ? ?tep_redirect(tep_href_link(FILENAME_HOMEPAGE, '', 'NONSSL')); ? ? ?break; ? ? ? ? case 'insert': ? ? ?case 'update': ? ? ? ?if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) { ? ? ? ? ?$action = 'new'; ? ? ? ?} else { ? ? ? ? ?if (isset($HTTP_GET_VARS['sID'])) $template_id = tep_db_prepare_input($HTTP_GET_VARS['sID']); ? ? ? ? ?$sql_data_array = array('name' => tep_db_prepare_input($HTTP_POST_VARS['name']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'title' => tep_db_prepare_input($HTTP_POST_VARS['title']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text1' => tep_db_prepare_input($HTTP_POST_VARS['text1']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'img' => tep_db_prepare_input($HTTP_POST_VARS['img']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'link' => tep_db_prepare_input($HTTP_POST_VARS['link']), ? ? ? ? ?'title2' => tep_db_prepare_input($HTTP_POST_VARS['title2']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text2' => tep_db_prepare_input($HTTP_POST_VARS['text2']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'img2' => tep_db_prepare_input($HTTP_POST_VARS['img2']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'link2' => tep_db_prepare_input($HTTP_POST_VARS['link2']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'mask' => tep_db_prepare_input($HTTP_POST_VARS['mask']), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'language_id' => tep_db_prepare_input($HTTP_POST_VARS['language_id'])); ? ? ? ? ?if ($action == 'insert') { ? ? ? ? ? ? ? ? ? ? ? ?tep_db_perform(TABLE_HOME, $sql_data_array); ? ? ? ? ? ?$template_id = tep_db_insert_id(); ? ? ? ? ? ?} elseif ($action == 'update') { ? ? ? ? ? ?tep_db_perform(TABLE_HOME, $sql_data_array, 'update', "template_id = '" . (int)$template_id . "'"); ? ? ? ? ?} ? ?tep_redirect(tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $template_id)); ? ? ? ?} ? ? ? ?break; // DELETE CONFIRM ? ? ?case 'deleteconfirm': ? ? ?$template_id = tep_db_prepare_input($HTTP_GET_VARS['sID']); ? ? ?tep_db_query("delete from " . TABLE_HOME . " where template_id = '" . tep_db_input($template_id) . "'"); ? ? ?tep_redirect(tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'])); ? ? ?break; ?} ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> <?php ?if ( ($HTTP_GET_VARS['action'] == 'new') || ($HTTP_GET_VARS['action'] == 'edit') ) { ?> <link rel="stylesheet" type="text/css" href="includes/javascript/calendar.css"> <script language="JavaScript" src="includes/javascript/calendarcode.js"></script> <?php ?} ?> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <div id="popupcalendar" class="text"></div> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> ?<tr> ? ?<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> ? ?</table></td> <!-- body_text //--> ? ?<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> ? ? ?<tr> ? ? ? ?<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td class="pageHeading"><?php echo HEADING_TITLE; ?></td> ? ? ? ? ? ?<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> <?php ?if ( ($HTTP_GET_VARS['action'] == 'new') || ($HTTP_GET_VARS['action'] == 'edit') ) { ? $form_action = 'preview'; ? ?if ( ($HTTP_GET_VARS['action'] == 'edit') && ($HTTP_GET_VARS['sID']) ) { ? ? ?$template_query = tep_db_query("select * from " . TABLE_HOME . " WHERE language_id='" . $languages_id . "' AND template_id='" .$sID. "'"); ? ? ?$template = tep_db_fetch_array($template_query); ? ? ?$sInfo = new objectInfo($template); ? ?} else { ? ? ?$sInfo = new objectInfo(array()); ? ?} ? // ADD & MODIFY ? ? //language FRENCH ? $sInfo->language_id=4; ? ? ?$modif_htm = fichier_to_string("templates/homepage_modif.htm"); ? ?$print=replace_champs("#name#", $sInfo->name, $modif_htm); ? ?$print=replace_champs("#id#", $sInfo->template_id, $print); ? ?$print=replace_champs("#text1#", $sInfo->text1, $print); ? ?$print=replace_champs("#text2#", $sInfo->text2, $print); ? ?$print=replace_champs("#title#", $sInfo->title, $print); ? ?$print=replace_champs("#title2#", $sInfo->title2, $print); ? ?$print=replace_champs("#img#", $sInfo->img, $print); ? ?$print=replace_champs("#img2#", $sInfo->img2, $print); ? ?$print=replace_champs("#language_id#", "$sInfo->language_id", $print); ? ? ? ? ? ?//DISPLAY PICTURES ? ?$print=replace_champs("#disp_title#", tep_image($dir_img.$sInfo->title), $print); ? ?$print=replace_champs("#disp_img#", tep_image($dir_img.$sInfo->img), $print); ? ?$print=replace_champs("#disp_title2#", tep_image($dir_img.$sInfo->title2), $print); ? ?$print=replace_champs("#disp_img2#", tep_image($dir_img.$sInfo->img2), $print); ? ? ? ?// MASK LIST ? ?$masklist_htm = fichier_to_string("templates/homepage_masklist.htm"); ? ?$mask=$sInfo->mask; ? ? ? ?for ($i=1;$i<=2;$i++) ? ? { ? ? if (($i=="$mask") || (($mask=="") && ($i==1))) { $checked="checked";} else {$checked="";} ? ? $maskimg=tep_image("images/home_mask".$i.".gif"); ? ? $temp=replace_champs("#mask#", $maskimg, $masklist_htm); ? ? $temp=replace_champs("#check#", $checked, $temp); ? ? $temp=replace_champs("#mask_value#", "$i", $temp); ? ? $masklist.=$temp; ? ? } ? ? ? ?$print_modif=replace_champs("#masklist#", $masklist, $print); ? ? ? ? ?> ? ? ?<tr><form name="preview" <?php echo 'action="' . tep_href_link(FILENAME_HOMEPAGE, tep_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action . (isset($HTTP_GET_VARS['sID']) ? '&sID=' . $HTTP_GET_VARS['sID'] : '') , 'NONSSL') . '"'; ?> method="post"><?php if ($form_action == 'update') echo tep_draw_hidden_field('template_id', $HTTP_GET_VARS['sID']); ?> ? ? ? ?<td><?php print($print_modif); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><table border="0" width="600px" cellspacing="0" cellpadding="2"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td class="main" align="left" valign="top"><br><?php echo (($form_action == 'preview') ? tep_image_submit('button_preview.gif', IMAGE_PREVIEW) : tep_image_submit('button_preview.gif', IMAGE_PREVIEW)). ' <a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $HTTP_GET_VARS['sID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</form></tr> <?php } elseif ($HTTP_GET_VARS['action'] == 'preview') ? ?{ ? ? ?//preview ? ? ?if (tep_not_null($HTTP_POST_VARS)) { ? ? ? ?$sInfo = new objectInfo($HTTP_POST_VARS); ? ? ?} else { ? ? ? ? $template_query = tep_db_query("select * from " . TABLE_HOME . " WHERE template_id='" .$sID); ? ? ? ? $template = tep_db_fetch_array($product_query); ? ? ? ? ? ? $sInfo = new objectInfo($template); ? ? ?} ? ? ? ? ? ?$form_action = (isset($HTTP_GET_VARS['sID'])) ? 'update' : 'insert'; ? ? ?$back_form_action = (isset($HTTP_GET_VARS['sID'])) ? 'edit' : 'new'; ? ? ?$print= fichier_to_string("templates/homepage_apercu.htm"); ? ? ? ? ? ?// SEE PREVIEW ? ? ?$mask_htm = fichier_to_string("templates/homepage/mask".$mask.".htm"); ? ? ?$temp=""; ? ? ? ? ? ?$title_disp=tep_image($dir_img.$sInfo->title); ? ? ?$temp=replace_champs("#title#",$title_disp,$mask_htm); ? ? ?$temp=replace_champs("#text#",$sInfo->text1,$temp); ? ? ?$temp=replace_champs("#text2#",$sInfo->text2,$temp); ? ? ?$title2_disp=tep_image($dir_img.$sInfo->title2); ? ? ?$temp=replace_champs("#title2#",$title2_disp,$temp); ? ? ?$img1_disp=tep_image($dir_img.$sInfo->img1); ? ? ?$temp=replace_champs("#img#",$img1_disp,$temp); ? ? ?$img2_disp=tep_image($dir_img.$sInfo->img2); ? ? ?$display=replace_champs("#img2#",$img2_disp,$temp); ? ? // Hidden values ? ? ?$hidden=tep_draw_hidden_field('template_id', (($template_id))); ? ? ?$hidden.=tep_draw_hidden_field('name', htmlspecialchars(stripslashes($name))); ? ? ?$hidden.=tep_draw_hidden_field('title', (stripslashes($title))); ? ? ?$hidden.=tep_draw_hidden_field('text1', htmlspecialchars(stripslashes($text1))); ? ? ?$hidden.=tep_draw_hidden_field('img', (stripslashes($img1))); ? ? ?$hidden.=tep_draw_hidden_field('title2', (stripslashes($title2))); ? ? ?$hidden.=tep_draw_hidden_field('text2', htmlspecialchars(stripslashes($text2))); ? ? ?$hidden.=tep_draw_hidden_field('img2', (stripslashes($img2))); ? ? ?$hidden.=tep_draw_hidden_field('link', (stripslashes($link))); ? ? ?$hidden.=tep_draw_hidden_field('link2', (stripslashes($link2))); ? ? ?$hidden.=tep_draw_hidden_field('mask', $mask); ? ? ?$hidden.=tep_draw_hidden_field('language_id', $language_id); ? ? ? ? ? ??> ? ? ? ? ?<?php ? ? ? ? ? ? echo tep_draw_form($form_action, FILENAME_HOMEPAGE, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['sID']) ? '&sID=' . $HTTP_GET_VARS['sID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"'); ? ? ? ? ? if ($form_action == 'update') echo tep_draw_hidden_field('template_id', $HTTP_GET_VARS['sID']); ?> ? ? ?<td><?php print($hidden); ?> ? ? ? ? ? ? ? <table width="600px" ?border="0" cellspacing="0" cellpadding="0"> ? ? ? ?<tr> ? ? ? ? ?<td><?php print($display); ?></td> ? ? ? ?</tr> ? ? ? ? </table></td> ? ? ? </tr> ? ? ? ? ?<?php ? ? ? ? // Preview without editing ? ? if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) ? ? { ? ? ? ?if (isset($HTTP_GET_VARS['origin'])) ? ? ? ?{ ? ? ? ?$pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0); ? ? ? ?if ($pos_params != false) ? ? ? ?{ ? ? ? ? ? $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params); ? ? ? ? ? $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1); ? ? ? ?} else ? ? ? ?{ ? ? ? ? ? $back_url = $HTTP_GET_VARS['origin']; ? ? ? ? ? $back_url_params = ''; ? ? ? ?} ? ? ? ?} else { ? ? ? $back_url = FILENAME_HOMEPAGE; ? ? ? $back_url_params = ?'sID=' . $sInfo->template_id; ? ? ? ?} ? ? ? ? ??> ? ? ? <tr> ? ? ?<td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td> ? ? ? </tr> ? ?<?php ? ?} else { ? ?> ? ? ?<tr> ? ? <td align="right" class="smallText"> ? <?php ? /* Re-Post all POST'ed variables */ ? ? ?reset($HTTP_POST_VARS); ? ? ?while (list($key, $value) = each($HTTP_POST_VARS)) { ? ? if (!is_array($HTTP_POST_VARS[$key])) { ? ? ? echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value))); ? ? } ? ? ?} ? ? ? ? ?echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . ' '; ? ? ? ?if (isset($HTTP_GET_VARS['sID'])) { ? ? echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ? ? ?} else { ? ? echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ? ? ?} ? ? ?echo ' <a href="' . tep_href_link(FILENAME_HOMEPAGE, ?(isset($HTTP_GET_VARS['sID']) ? 'sID=' . $HTTP_GET_VARS['sID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ? ?></td> ? ? ?</tr> ? ?</table></form> ? <?php ? ?} ?} else { // MAIN PAGE ?> ? ? ?<tr> ? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> ? ? ? ? ? ? ?<tr class="dataTableHeadingRow"> ? ? ? ? ? ? ? ?<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TEMPLATE; ?></td> ? ? ? ? ? ? ? ?<td class="dataTableHeadingContent" align="right"> </td> ? ? ? ? ? ? ? ?<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td> ? ? ? ? ? ? ? ?<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> ? ? ? ? ? ? ?</tr> <?php ? ?$template_query_raw = "select * from ".TABLE_HOME." WHERE language_id='" . $languages_id . "' order by sort_order"; ? ?$template_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $template_query_raw, $template_query_numrows); ? ?$template_query = tep_db_query($template_query_raw); ? ?while ($template = tep_db_fetch_array($template_query)) { ? ? ?if ( ((!$HTTP_GET_VARS['sID']) || ($HTTP_GET_VARS['sID'] == $template['template_id'])) && (!$sInfo) ) { ? ? ? ?$theone_query = tep_db_query("select * from " . TABLE_HOME . " where template_id = '" . $template['template_id'] . "'"); ? ? ? ?$theone = tep_db_fetch_array($theone_query); ? ? ? ?$sInfo = new objectInfo($theone); ? ? ?} ? ? ?if ( (is_object($sInfo)) && ($template['template_id'] == $sInfo->template_id) ) { ? ? ? ?echo ' ? ? ? ? ? ? ? ? ?<tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->template_id . '&action=edit') . '\'">' . "\n"; ? ? ?} else { ? ? ? ?echo ' ? ? ? ? ? ? ? ? ?<tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $template['template_id']) . '\'">' . "\n"; ? ? ?} ?> ? ? ? ? ? ? ? ?<td ?class="dataTableContent"><?php echo $template['name']; ?></td> ? ? ? ? ? ? ? ?<td ?class="dataTableContent" align="right"> </td> ? ? ? ? ? ? ? ?<td ?class="dataTableContent" align="right"> <?php ? ? ?if ($template['status'] == '1') { ? ? ? ?echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_HOMEPAGE, 'action=setflag&flag=0&id=' . $featured['featured_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>'; ? ? ?} else { ? ? ? ?echo '<a href="' . tep_href_link(FILENAME_HOMEPAGE, 'action=setflag&flag=1&id=' . $template['template_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); ? ? ?} ?></td> ? ? ? ? ? ? ? ?<td class="dataTableContent" align="right"><?php if ( (is_object($sInfo)) && ($template['template_id'] == $sInfo->template_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $template['template_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> ? ? ?</tr> <?php ? ?} ?> ? ? ? ? ? ? ?<tr> ? ? ? ? ? ? ? ?<td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2"> ? ? ? ? ? ? ? ? ?<tr> ? ? ? ? ? ? ? ? ? ?<td class="smallText" valign="top"><?php echo $template_split->display_count($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_TEMPLATE); ?></td> ? ? ? ? ? ? ? ? ? ?<td class="smallText" align="right"><?php echo $template_split->display_links($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td> ? ? ? ? ? ? ? ? ?</tr> <?php ?if (!$HTTP_GET_VARS['action']) { ?> ? ? ? ? ? ? ? ? ?<tr> ? ? ? ? ? ? ? ? ? ?<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new.gif', IMAGE_NEW) . '</a>'; ?></td> ? ? ? ? ? ? ? ? ?</tr> <?php ?} ?> ? ? ? ? ? ? ? ?</table></td> ? ? ? ? ? ? ?</tr> ? ? ? ? ? ?</table></td> <?php ?$heading = array(); ?$contents = array(); ?switch ($HTTP_GET_VARS['action']) { ? //DELETE ? ?case 'delete': ? ? ?$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_TEMPLATE . '</b>'); ? ? ?$contents = array('form' => tep_draw_form('template', FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->template_id . '&action=deleteconfirm')); ? ? ?$contents[] = array('text' => TEXT_INFO_DELETE_INTRO); ? ? ?$contents[] = array('text' => '<br><b>' . $sInfo->name . '</b>'); ? ? ?$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->template_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); ? ? ?break; ? ?default: ? ? ?if (is_object($sInfo)) { ? ? // info of the selected item ? ? ? ?$heading[] = array('text' => '<b>' . $sInfo->name . '</b>'); ? ? ? ?$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->template_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_HOMEPAGE, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->template_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); ?$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image("images/home_mask" . $sInfo->mask . ".gif", $sInfo->name)); ? ? ?} ? ? ?break; ?} ?if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { ? ?echo ' ? ? ? ? ? ?<td width="25%" valign="top">' . "\n"; ? ?$box = new box; ? ?echo $box->infoBox($heading, $contents); ? ?echo ' ? ? ? ? ? ?</td>' . "\n"; ?} } ?> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> ? ?</table></td> <!-- body_text_eof //--> ?</tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Edited September 24, 2005 by Johnson Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
Guest Posted September 24, 2005 Posted September 24, 2005 Ok, you added the code for the re-post are there any language dependent variables that need posting? I noticed you are using languages but there are no language depended fields in the re-post section. Then when you post you setup the sID in the form (tep_draw_form) but you also have that in the link (the new code added) echo ' <a href="' . tep_href_link(FILENAME_HOMEPAGE, (isset($HTTP_GET_VARS['sID']) ? 'sID=' . $HTTP_GET_VARS['sID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; so you shouldnt need the parameter double posted in the form and in the button. You also pass the same value through the 'template_id' just below the tep_draw_form Now in the tep_draw_form you set the 'action' variable based on the $form_action which can be only 'update' or 'insert'. The $back_form_action can be set to 'edit' (the one you need to go back) but the variable is unused. Quote
celia_ccs Posted September 29, 2005 Author Posted September 29, 2005 Hi, thanks for the help. I manage to make it work fine. I finish the development of the contribution. You can download it at this address : http://www.oscommerce.com/community/contributions,3579 I would appreciate if some of you could try it and report me any bugs. I'll try to add a few more features very soon. Celia B) Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
dbel Posted October 28, 2005 Posted October 28, 2005 Hi, thanks for the help. I manage to make it work fine. I finish the development of the contribution. You can download it at this address : http://www.oscommerce.com/community/contributions,3579 I would appreciate if some of you could try it and report me any bugs. I'll try to add a few more features very soon. Celia B) I included the contribution to my website and got this error : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/reahost5/public_html/homepage.php on line 18 The products shown are for demonstrational purposes, any products purchased will not be delivered nor will the customer be billed. Any information seen on these products is to be treated as fictional. Quote
celia_ccs Posted October 31, 2005 Author Posted October 31, 2005 Hi, I guess you didn't update the file includes/database_tables.php . You should add the following : define('TABLE_HOME', 'homepage'); Try with this and let me know if it works better. Celia Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
spottedhaggis Posted November 14, 2005 Posted November 14, 2005 I have installed this contrib, and made all the required file changes, and then imported the following info into my database, however I get an error on running the script below. SCRIPT I RUN -- -- Structure of table `homepage` -- DROP TABLE IF EXISTS `homepage`; CREATE TABLE `homepage` ( `template_id` int(4) NOT NULL auto_increment, `language_id` int(11) NOT NULL default '0', `name` varchar(40) NOT NULL default '', `title` varchar(60) NOT NULL default '', `text1` text NOT NULL, `img` varchar(40) NOT NULL default '', `link` varchar(40) NOT NULL default '', `title2` varchar(60) NOT NULL default '', `text2` text NOT NULL, `img2` varchar(40) NOT NULL default '', `link2` varchar(40) NOT NULL default '', `mask` int(11) NOT NULL default '0', `sort_order` int(11) NOT NULL default '0', `status` int(11) NOT NULL default '0', PRIMARY KEY (`template_id`) ) TYPE=MyISAM AUTO_INCREMENT=18 ; -- -- add to table `homepage` -- INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); ERROR I RECEIVE MySQL said: #1136 - Column count doesn't match value count at row 1 I assume this is because the inserted data is not the same number of parameters as the table structure, but my sql knowledge is limited so I am not sure how to fix it. Quote Born - Scotland Location - Kent, England Job - hunting for one
celia_ccs Posted November 15, 2005 Author Posted November 15, 2005 INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); MySQL said: #1136 - Column count doesn't match value count at row 1 This is because the user PicsOne made a change on the contribution, but it shouldn't be. The right SQL function is : INSERT INTO `admin_files` VALUES ('', 'homepage.php', 0, 3, '1,3'); Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
spottedhaggis Posted November 15, 2005 Posted November 15, 2005 Actually I did have that one the first time but it would not work either, so I manually input the field homepage and this has resolved the problem perfectly. So, in summary botht he Admin and homepage sql script will not enter, because the actual section you are entering it into has something along the lines of 12 or more fields, and the column count variable for this sql has only 5 shown Manual entry was the only way to make the sql change work for me, and it worked fine Quote Born - Scotland Location - Kent, England Job - hunting for one
zankel Posted November 21, 2005 Posted November 21, 2005 Actually I did have that one the first time but it would not work either, so I manually input the field homepage and this has resolved the problem perfectly. So, in summary botht he Admin and homepage sql script will not enter, because the actual section you are entering it into has something along the lines of 12 or more fields, and the column count variable for this sql has only 5 shown Manual entry was the only way to make the sql change work for me, and it worked fine Hi, Can you please write down how you did it exactly? I'm really new to this. Thanks. Quote
spottedhaggis Posted November 21, 2005 Posted November 21, 2005 Well, you need to access your web hosting company control panel, most hosts hvae something of a control panel. I expect, like most, it will allow you to manipulate your database using PHPMyAdmin Access this, or whatever database software package they provide. Select your database OSC You should see a list of around 40+ sections, from customers to Orders. Select Customers and you should be presented withthe fields that make up this section. Customers_id, Customers_Gender etc etc select the sql option and paste the additional information in the install of this contrib. If yours works like mine, the field createaccount will enter ok but the field confirmation_key will error So, now I did some screenshots for you You should see this by now, without the confirmation key field in this image Sorry it is a little crued but hope it helps. http://www.spottedhaggis.com/page1.htm second image http://www.spottedhaggis.com/page2.htm Sorry this is a little crued but may help http://www.spottedhaggis.com/p[age1 Quote Born - Scotland Location - Kent, England Job - hunting for one
zankel Posted November 22, 2005 Posted November 22, 2005 Well, you need to access your web hosting company control panel, most hosts hvae something of a control panel. I expect, like most, it will allow you to manipulate your database using PHPMyAdmin Access this, or whatever database software package they provide. Select your database OSC You should see a list of around 40+ sections, from customers to Orders. Select Customers and you should be presented withthe fields that make up this section. Customers_id, Customers_Gender etc etc select the sql option and paste the additional information in the install of this contrib. If yours works like mine, the field createaccount will enter ok but the field confirmation_key will error So, now I did some screenshots for you You should see this by now, without the confirmation key field in this image Sorry it is a little crued but hope it helps. http://www.spottedhaggis.com/page1.htm second image http://www.spottedhaggis.com/page2.htm Sorry this is a little crued but may help http://www.spottedhaggis.com/p[age1 Hi, First of all - Thanks for the help. Second, I don't understand where did this "confirmation_key" come from? Unless we're talking about a different contrib. What I was asking about was this line: INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); that didn't work for me. BTW: Where am I supposed to see it in the Admin panel? Thanks again. Quote
spottedhaggis Posted November 22, 2005 Posted November 22, 2005 ok, I tried this and it failed consistantly, the main reason would appear that there is no table called admin_files in the OSC installation, and at no time has one ever been requested creating. Are we sure this should go into admin_files, where ever that may be Quote Born - Scotland Location - Kent, England Job - hunting for one
zankel Posted November 22, 2005 Posted November 22, 2005 ok, I tried this and it failed consistantly, the main reason would appear that there is no table called admin_files in the OSC installation, and at no time has one ever been requested creating. Are we sure this should go into admin_files, where ever that may be I didn't write admin_files, that was on the original contrib. I addressed the homepage table which was fixed with a contribution: INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); MySQL said: #1136 - Column count doesn't match value count at row 1 Then, has anyone been able to install it? Should I just remove it from the site? What do you suggest? This is because the user PicsOne made a change on the contribution, but it shouldn't be. The right SQL function is : INSERT INTO `admin_files` VALUES ('', 'homepage.php', 0, 3, '1,3'); Hi celia ccs, Could you please try to address my questions posted here as well? spottedhaggis is trying to help but you are this contribution's writer and you know it inside and out, right? Anyway, thanks to both of you! Quote
celia_ccs Posted November 22, 2005 Author Posted November 22, 2005 Hi, I'm sorry about the admin_file issue. After looking a bit at my installation of OS Commerce, I found out that this table exist since the installation of the Contrib AdminMS2. If you don't have this Contrib installed you don't need to update that table. However, the purpose of this SQL insert was to access the Homepage page in the admin section. In the admin section you need to access the page admin/homepage.php to be able to configure this contribution. But I don't know how to make sure it appaeras in the left navigation. any idea? Thanks, Celia Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
spottedhaggis Posted November 22, 2005 Posted November 22, 2005 hI, I have to be honest, with this one I gave up completely. The SQL script, where you create the table has 14 fields for data, as follows Template_id Language_id name title text1 img link title2 text2 img2 link2 mask sort_order status This table using the sql script provided can be created without error. Then the script asks us to insert a string of entres into the above fields, however as you can see from the script, it is missing a few things. INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); Between each of the single quote ( ' ) is a field entry, and though I lack any real detailed knowledge of MySQL, logic states (in my mind at least) that there need to be 14 entries, and if there are not 14 entries, how can the script determine that the 0 or the 3 have been placed into the correct fields, this would mean the following template_id = (blank) Language_id = homepage.php name = 0 title = 3 text1 = 1 img = 3 the rest are unknown. The error I receive from Mysql is as follows MySQL said: #1136 - Column count doesn't match value count at row 1 (there is only one row) This in simple terms means you have a table with 14 fields for entry of data and are trying to insert only 6 entries, and the table has no way of knowing where these values need to go. If you had 14 values in this line, it would most likely work, values depending. I hope this has helped you undrstand the problem, and sadly only guess work will let us figure it out, as I have no idea what the numers correspond to This line for entry will work, only I have not included any real data into it, and again have no idea what the numbers above are for, and do not see if it will help. INSERT INTO `homepage` VALUES ('','0','','','text description here','','','','tex description here also','','','0',0,0); Quote Born - Scotland Location - Kent, England Job - hunting for one
celia_ccs Posted November 22, 2005 Author Posted November 22, 2005 hI,I have to be honest, with this one I gave up completely. The SQL script, where you create the table has 14 fields for data, as follows Template_id Language_id name title text1 img link title2 text2 img2 link2 mask sort_order status This table using the sql script provided can be created without error. Then the script asks us to insert a string of entres into the above fields, however as you can see from the script, it is missing a few things. Between each of the single quote ( ' ) is a field entry, and though I lack any real detailed knowledge of MySQL, logic states (in my mind at least) that there need to be 14 entries, and if there are not 14 entries, how can the script determine that the 0 or the 3 have been placed into the correct fields, this would mean the following template_id = (blank) Language_id = homepage.php name = 0 title = 3 text1 = 1 img = 3 the rest are unknown. The error I receive from Mysql is as follows MySQL said: #1136 - Column count doesn't match value count at row 1 (there is only one row) This in simple terms means you have a table with 14 fields for entry of data and are trying to insert only 6 entries, and the table has no way of knowing where these values need to go. If you had 14 values in this line, it would most likely work, values depending. I hope this has helped you undrstand the problem, and sadly only guess work will let us figure it out, as I have no idea what the numers correspond to This line for entry will work, only I have not included any real data into it, and again have no idea what the numbers above are for, and do not see if it will help. INSERT INTO `homepage` VALUES ('','0','','','text description here','','','','tex description here also','','','0',0,0); ok .. there is really a confusion here .. INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); that insert was not supposed to be in the "homepage" table but the "admin_file" table. Someone did an errouneous change to the contribution. And as said just before this insert should only be done if you have installed the AdminMS2 contrib because the purpose is to give an access to the "homepage admin page" in teh Admin section. I'm going to do the change right away on the contrib so this mistake doesn't appear anymore. Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
spottedhaggis Posted November 22, 2005 Posted November 22, 2005 hi, ok, after inserting that line, and making the required file changes, its now fully operational. to run it simply goto http://www.yourwebsitename.com/admin/homepage.php I take it back, I am getting errors when I try to do things with it. Honestly I would not use it, its buggy and unfortunatly commented in French so I cant even work out what I am looking at. Its calling on files that are not included in the downloaded filestructure, so I am not using it. sorry to the creator, would have been nice if it worked, and made a difference to the main page updates, but it does not work. Quote Born - Scotland Location - Kent, England Job - hunting for one
zankel Posted November 22, 2005 Posted November 22, 2005 ok .. there is really a confusion here .. INSERT INTO `homepage` VALUES ('', 'homepage.php', 0, 3, '1,3'); that insert was not supposed to be in the "homepage" table but the "admin_file" table. Someone did an errouneous change to the contribution. And as said just before this insert should only be done if you have installed the AdminMS2 contrib because the purpose is to give an access to the "homepage admin page" in teh Admin section. I'm going to do the change right away on the contrib so this mistake doesn't appear anymore. I see. What is the link to the AdminMS2 contrib? Quote
celia_ccs Posted November 22, 2005 Author Posted November 22, 2005 Its calling on files that are not included in the downloaded filestructure, so I am not using it. Can you tell me what files is it calling that is not in the package? I'm using this contribution on my site and it's working good. But my version of OSCommerce has quite a lot of modification. About the French comments, I've seen the file you're refering to, I'm translating and uploading a new version in the contribution page. I see. What is the link to the AdminMS2 contrib? http://www.oscommerce.com/community/contributions,1359 It's easy to install and quite interesting. :thumbsup: Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
fatmcgav Posted November 23, 2005 Posted November 23, 2005 Anybody got a demo store with this installed that i can have a look at? Cheers Fatmcgav Quote
celia_ccs Posted November 23, 2005 Author Posted November 23, 2005 Yes on this site that I'm currently developping : http://www.moileheros.com/catalog/ all the content in the center above "Nos coups de coeur" come from Homepage design contrib. That's just an exemple of how it could look. because actually the idea of this contribution is that you create your template in HTML and then integrate the content + image in the admin section. But for now you have 2 add the new templates manually .. I haven't add this feature in the admin section yet. sorry bit busy those days .. :huh: Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
zankel Posted November 23, 2005 Posted November 23, 2005 Can you tell me what files is it calling that is not in the package? I'm using this contribution on my site and it's working good. But my version of OSCommerce has quite a lot of modification. About the French comments, I've seen the file you're refering to, I'm translating and uploading a new version in the contribution page. http://www.oscommerce.com/community/contributions,1359 It's easy to install and quite interesting. :thumbsup: Hi Celia_ccs, I tried to install the Admin Access contrib but it quite destroyed my store (probably because I'm not using the default store - Lots of Add-Ons) So, I guess i'll be leaving your contrib. Thanks anyway for trying to help. Zankel Quote
ajptravis Posted November 24, 2005 Posted November 24, 2005 Hi - I'm a newbie but after install decided to install your contribution of Homepage Design v0.2. I have copied all files as instructed. On running SQL query I ran DROP TABLE IF EXISTS `homepage`; CREATE TABLE `homepage` ( `template_id` int(4) NOT NULL auto_increment, `language_id` int(11) NOT NULL default '0', `name` varchar(40) NOT NULL default '', `title` varchar(60) NOT NULL default '', `text1` text NOT NULL, `img` varchar(40) NOT NULL default '', `link` varchar(40) NOT NULL default '', `title2` varchar(60) NOT NULL default '', `text2` text NOT NULL, `img2` varchar(40) NOT NULL default '', `link2` varchar(40) NOT NULL default '', `mask` int(11) NOT NULL default '0', `sort_order` int(11) NOT NULL default '0', `status` int(11) NOT NULL default '0', PRIMARY KEY (`template_id`) ) TYPE=MyISAM AUTO_INCREMENT=18 ; This was OK I then attempted to run : - -- add to table `admin_files` -- INSERT INTO `admin_files` VALUES ('', 'homepage.php', 0, 3, '1,3'); which error'd I ran INSERT INTO `admin_files` VALUES ('', 'homepage.php', 0, 3, '1,3'); and it gave me #1146 - Table 'travisf_os.admin_files' doesn't exist Can you help as my whole site doesn't work now Regards Andy Quote
celia_ccs Posted November 24, 2005 Author Posted November 24, 2005 Hi Andy, If you really downloaded the last version from Nov 22nd, u would see that the SQL insert is as follow. Try it, and let me know if it works. -- -- Structure of table `homepage` -- DROP TABLE IF EXISTS `homepage`; CREATE TABLE `homepage` ( `template_id` int(4) NOT NULL auto_increment, `language_id` int(11) NOT NULL default '0', `name` varchar(40) NOT NULL default '', `title` varchar(60) NOT NULL default '', `text1` text NOT NULL, `img` varchar(40) NOT NULL default '', `link` varchar(40) NOT NULL default '', `title2` varchar(60) NOT NULL default '', `text2` text NOT NULL, `img2` varchar(40) NOT NULL default '', `link2` varchar(40) NOT NULL default '', `mask` int(11) NOT NULL default '0', `sort_order` int(11) NOT NULL default '0', `status` int(11) NOT NULL default '0', PRIMARY KEY (`template_id`) ) TYPE=MyISAM AUTO_INCREMENT=18 ; Quote ----------------------------------------- OSCommerce version : MS2 Contributions installed : AdminMS2, Dynamic Mopics V3, WYSIWYG HTML Area MS2, Easypopulate
tonyh Posted June 1, 2006 Posted June 1, 2006 Hi there. Have installed without problems but can not implement the mod. The index page is blank on the center and the right column even after adding a templete in admin. The template supplied is not showing up anywhere. I have already inserted and confirmed in the database the data for the template. In admin I get the following error (on ...homepage.php?page=1&action=preview...) when I try to update the template I have added. Warning: file(templates/homepage/mask2.htm): failed to open stream: No such file or directory in /home/mysite/public_html/shop/admin/includes/functions/globalfunction.php on line 51 and there will be nothing to preview. This seems to be a problem to do with URL of the templates/homepage/mask2.htm. Help me out Please! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.