Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

If- else statement?


magnusj

Recommended Posts

Hi,

I?m trying to use the category field "categories_heading_title" as an external url link.

 

If you enter for instance "http://www.google.com" in that field, the category menu item should link to Google. If the field is left blank, the menu item should link to the category page (id) as usual.

 

Since i?m not very wise in the ways of php I really need some help.

 

I have tried something like this in the category box:

 

if($categories['categories_heading_title'] == 0) {

$categories_string .= $foo[$category_counter]['url'];

} else {

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

}

 

and further down:

 

while ($categories = tep_db_fetch_array($categories_query)) {

$foo[$categories['categories_id']] = array(

'name' => $categories['categories_name'],

'url' => $categories['categories_heading_title'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false

);

 

 

It doesn?t work... Plesae, if anyone could help I would really be greatful!

 

Magnus J

Link to comment
Share on other sites

...or maybe there is a way to implement the "external page" and "target" function used in the "Information Pages" contrib? But working on categories instead of pages.

 

Anyone?

 

Please...

Link to comment
Share on other sites

actually you should use your array for the check (first part of the code) which is $foo. Why do you expect $categories to be an array?

 

if($foo[$category_counter]['categories_heading_title'] == 0) {

 

and your box must be quite custom so if that doesnt work post the entire box file.

Link to comment
Share on other sites

Hi enigma1.

thanks for your reply.

 

Well, let me try again. I might have messed up the code before. You see I have made a sort of cms section to osCommerce by duplicating the "categories" files and changing all instances of "categories" to "xpagecat"... and so on. When I posted here I tried to quickly change it back. Forget it.

 

Anyway, here is what my xpagecat box actually looks like in full:

 

 

function tep_show_xpagecategory_top($xpage_counter) {

global $foo, $xpagecat_string, $id;

 

for ($a=0; $a<$foo[$xpage_counter]['level']; $a++) {

$xpagecat_string .= "";

}

 

$xpagecat_string .= '<span class="topnav"><a href="';

 

if ($foo[$xpage_counter]['parent'] == 0) {

$cXpagePath_new = 'cXpagePath=' . $xpage_counter;

} else {

$cXpagePath_new = 'cXpagePath=' . $foo[$xpage_counter]['path'];

}

 

 

// make url link instead

if($xpagecat['xpagecat_heading_title'] == 0) {

$xpagecat_string .= $foo[$xpage_counter]['url'];

} else {

$xpagecat_string .= tep_href_link(FILENAME_DEFAULTXPAGE, $cXpagePath_new);

}

 

 

 

$xpagecat_string .= '">';

 

if ( ($id) && (in_array($xpage_counter, $id)) ) {

$xpagecat_string .= '<b>';

}

 

// display category name

$xpagecat_string .= $foo[$xpage_counter]['name'];

 

if ( ($id) && (in_array($xpage_counter, $id)) ) {

$xpagecat_string .= '</b>';

}

 

if (tep_has_xpagecategory_subcategories($xpage_counter)) {

$xpagecat_string .= '';

}

 

$xpagecat_string .= '</a></span>';

 

$xpagecat_string .= '';

 

if ($foo[$xpage_counter]['next_id']) {

tep_show_xpagecategory_top($foo[$xpage_counter]['next_id']);

}

 

 

}

?>

<!-- xpagescat //-->

 

<?php

 

$xpagecat_string = '';

 

 

$xpagecat_query = tep_db_query("select c.xpagecat_id, cd.xpagecat_name, cd.xpagecat_heading_title, c.parent_id from " . TABLE_XPAGECAT . " c, " . TABLE_XPAGECAT_DESCRIPTION . " cd where c.parent_id = '0' and c.xpagecat_id = cd.xpagecat_id and cd.language_id='" . $languages_id ."' and c.xpagecat_status = '1' order by sort_order, cd.xpagecat_name, cd.xpagecat_heading_title");

while ($xpagecat = tep_db_fetch_array($xpagecat_query)) {

$foo[$xpagecat['xpagecat_id']] = array(

'name' => $xpagecat['xpagecat_name'],

'url' => $xpagecat['xpagecat_heading_title'],

'parent' => $xpagecat['parent_id'],

'level' => 0,

'path' => $xpagecat['xpagecat_id'],

'next_id' => false

);

 

if (isset($art_prev_id)) {

$foo[$art_prev_id]['next_id'] = $xpagecat['xpagecat_id'];

}

 

$art_prev_id = $xpagecat['xpagecat_id'];

 

if (!isset($art_first_element)) {

$art_first_element = $xpagecat['xpagecat_id'];

}

}

 

//------------------------

 

 

tep_show_xpagecategory_top($art_first_element);

 

$info_box_contents = array();

$info_box_contents[] = array('align' => 'left',

'text' => $xpagecat_string

);

new infoBox($info_box_contents);

 

 

If I fill in the category field "categories_heading_title" in Admin with say "http://www.google.com",'>http://www.google.com", the code above actually turns the menu item into an external link (http://www.google.com). If I fill in the word "forum", the menu item displays as "http://www.mywebsite.com/folder/forum". Nice if I wanna make some modules. But... if I fill in nothing, the menu item displays as "http://www.mywebsite.com/folder/". It should display the normal page, for instance "http://www.mywebsite.com/folder/defaultxpage.php?cXpagePath=9".

 

If I cange "if($xpagecat['xpagecat_heading_title'] == 0) { " to "if($xpagecat['xpagecat_heading_title'] == 0) { " in the code above, the menu items are ALL shown as normal pages. Filled in or not.

 

I tried your suggestion, but I can?t get it to work. As I said, I?m not really sure what I?m doing when it comes to php and database handling. But I?m a really nice guy ;-)

 

Hope U understand my english. Any help is greatly appreciated. Thanks!

 

M

Link to comment
Share on other sites

this

 

// make url link instead

if($xpagecat['xpagecat_heading_title'] == 0) {

 

 

where $xpagecat is defined/initialized? I don't see it anywhere in the function. So it should be

 

// make url link instead

if($foo[$xpage_counter]['xpagecat_heading_title'] == 0) {

 

because $foo is your global array.

Link to comment
Share on other sites

Hi again!

Well, I tried to change

 

// make url link instead

if($xpagecat['xpagecat_heading_title'] == 0) {

 

to

 

// make url link instead

if($foo[$xpage_counter]['xpagecat_heading_title'] == 0) {

 

...but it did nothing.

 

So, the thing that is NOT working is the "else"-thing. Like I said before, when the "categories_heading_title" field in Admin is left blank, the menu item is displyed as "http://www.mywebsite.com/folder/". Not "http://www.mywebsite.com/folder/defaultxpage.php?cXpagePath=9".

 

Could it be a database thing? The query?

 

Ahhh nuts...

Link to comment
Share on other sites

I don't know about the admin side obviously how you set it up. But if you're looking for an empty string, try doing this instead.

 

if( !tep_not_null($foo[$xpage_counter]['xpagecat_heading_title']) ) {

 

You mentioned you expect the "if" to go through when no heading_title is defined so it should go through the "if" not the "else". And make sure on the admin end the 'url' field is populated.

Link to comment
Share on other sites

Nope, can?t get it to work. Still shows all menu items in the same way. No difference if the field is filled in or not.

 

Now I have:

// make url link instead   
if(!tep_not_null($foo[$xpage_counter]['xpagecat_heading_title']) ) {
$xpagecat_string .= $foo[$xpage_counter]['url'];
} else {
$xpagecat_string .= tep_href_link(FILENAME_DEFAULTXPAGE, $cXpagePath_new);
}

 

 

Here is my admin page (if it helps). Sorry, I don?t want to tie you up. I really appreciate your help :-)

 

 

require('includes/application_top.php');

require('includes/functions/xpagecat_description.php');

 

if ($HTTP_GET_VARS['action']) {

switch ($HTTP_GET_VARS['action']) {

 

// ####################### Added Categories Enable / Disable ###############

case 'setflag_cat':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {

if (isset($HTTP_GET_VARS['cID'])) {

tep_set_xpagecat_status($HTTP_GET_VARS['cID'], $HTTP_GET_VARS['flag']);

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('xpagecat');

}

}

 

tep_redirect(tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&cID=' . $HTTP_GET_VARS['cID']));

break;

// ####################### End Categories Enable / Disable ###############

 

case 'new_category':

case 'edit_category':

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true')

$HTTP_GET_VARS['action']=$HTTP_GET_VARS['action'] . '_ACD';

break;

case 'insert_category':

case 'update_category':

if ( ($HTTP_POST_VARS['edit_x']) || ($HTTP_POST_VARS['edit_y']) ) {

$HTTP_GET_VARS['action'] = 'edit_category_ACD';

} else {

if (isset($HTTP_POST_VARS['xpagecat_id'])) $xpagecat_id = tep_db_prepare_input($HTTP_POST_VARS['xpagecat_id']);

if ($xpagecat_id == '') {

$xpagecat_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

}

$sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

 

$sql_data_array = array('sort_order' => $sort_order);

 

// ####################### Added Categories Enable / Disable ###############

// $sql_data_array = array('sort_order' => $sort_order);

$xpagecat_status = tep_db_prepare_input($HTTP_POST_VARS['xpagecat_status']);

$sql_data_array = array('sort_order' => $sort_order, 'xpagecat_status' => $xpagecat_status);

// ####################### End Added Categories Enable / Disable ###############

 

if ($HTTP_GET_VARS['action'] == 'insert_category') {

$insert_sql_data = array('parent_id' => $current_category_id,

'date_added' => 'now()');

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

tep_db_perform(TABLE_XPAGECAT, $sql_data_array);

$xpagecat_id = tep_db_insert_id();

} elseif ($HTTP_GET_VARS['action'] == 'update_category') {

$update_sql_data = array('last_modified' => 'now()');

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

tep_db_perform(TABLE_XPAGECAT, $sql_data_array, 'update', 'xpagecat_id = \'' . $xpagecat_id . '\'');

}

 

$languages = tep_get_languages();

for ($i=0; $i<sizeof($languages); $i++) {

$xpagecat_name_array = $HTTP_POST_VARS['xpagecat_name'];

$language_id = $languages[$i]['id'];

$sql_data_array = array('xpagecat_name' => tep_db_prepare_input($xpagecat_name_array[$language_id]));

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {

$sql_data_array = array('xpagecat_name' => tep_db_prepare_input($HTTP_POST_VARS['xpagecat_name'][$language_id]),

'xpagecat_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['xpagecat_heading_title'][$language_id]),

'xpagecat_description' => tep_db_prepare_input($HTTP_POST_VARS['xpagecat_description'][$language_id]));

}

if ($HTTP_GET_VARS['action'] == 'insert_category') {

$insert_sql_data = array('xpagecat_id' => $xpagecat_id,

'language_id' => $languages[$i]['id']);

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

tep_db_perform(TABLE_XPAGECAT_DESCRIPTION, $sql_data_array);

} elseif ($HTTP_GET_VARS['action'] == 'update_category') {

tep_db_perform(TABLE_XPAGECAT_DESCRIPTION, $sql_data_array, 'update', 'xpagecat_id = \'' . $xpagecat_id . '\' and language_id = \'' . $languages[$i]['id'] . '\'');

}

}

 

 

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {

tep_db_query("update " . TABLE_XPAGECAT . " set xpagecat_image = '" . $HTTP_POST_VARS['xpagecat_image'] . "' where xpagecat_id = '" . tep_db_input($xpagecat_id) . "'");

$xpagecat_image = '';

} else {

if ($xpagecat_image = new upload('xpagecat_image', DIR_FS_CATALOG_IMAGES)) {

tep_db_query("update " . TABLE_XPAGECAT . " set xpagecat_image = '" . tep_db_input($xpagecat_image->filename) . "' where xpagecat_id = '" . (int)$xpagecat_id . "'");

}

}

 

tep_redirect(tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $xpagecat_id));

}

break;

case 'delete_category_confirm':

if ($HTTP_POST_VARS['xpagecat_id']) {

$xpagecat_id = tep_db_prepare_input($HTTP_POST_VARS['xpagecat_id']);

 

$xpagecat = tep_get_category_tree2($xpagecat_id, '', '0', '', true);

 

for ($i=0; $i<sizeof($xpagecat); $i++) {

tep_remove_xpagecat($xpagecat[$i]['id']);

}

 

}

tep_redirect(tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $cPath));

break;

 

case 'move_category_confirm':

if ( ($HTTP_POST_VARS['xpagecat_id']) && ($HTTP_POST_VARS['xpagecat_id'] != $HTTP_POST_VARS['move_to_category_id']) ) {

$xpagecat_id = tep_db_prepare_input($HTTP_POST_VARS['xpagecat_id']);

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

tep_db_query("update " . TABLE_XPAGECAT . " set parent_id = '" . tep_db_input($new_parent_id) . "', last_modified = now() where xpagecat_id = '" . tep_db_input($xpagecat_id) . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('xpagecat');

}

}

 

tep_redirect(tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $new_parent_id . '&cID=' . $xpagecat_id));

break;

}

}

 

// check if the catalog image directory exists

if (is_dir(DIR_FS_CATALOG_IMAGES)) {

if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');

} else {

$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="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>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">

<!-- 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">

<?php

//----- new_category / edit_category (when ALLOW_CATEGORY_DESCRIPTIONS is 'true') -----

if ($HTTP_GET_VARS['action'] == 'new_category_ACD' || $HTTP_GET_VARS['action'] == 'edit_category_ACD') {

if ( ($HTTP_GET_VARS['cID']) && (!$HTTP_POST_VARS) ) {

$xpagecat_query = tep_db_query("select c.xpagecat_id, cd.xpagecat_name, cd.xpagecat_heading_title, cd.xpagecat_description, c.xpagecat_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_XPAGECAT . " c, " . TABLE_XPAGECAT_DESCRIPTION . " cd where c.xpagecat_id = '" . $HTTP_GET_VARS['cID'] . "' and c.xpagecat_id = cd.xpagecat_id and cd.language_id = '" . $languages_id . "' order by c.sort_order, cd.xpagecat_name");

$category = tep_db_fetch_array($xpagecat_query);

 

$cInfo = new objectInfo($category);

} elseif ($HTTP_POST_VARS) {

$cInfo = new objectInfo($HTTP_POST_VARS);

$xpagecat_name = $HTTP_POST_VARS['xpagecat_name'];

$xpagecat_heading_title = $HTTP_POST_VARS['xpagecat_heading_title'];

$xpagecat_description = $HTTP_POST_VARS['xpagecat_description'];

$xpagecat_url = $HTTP_POST_VARS['xpagecat_url'];

} else {

$cInfo = new objectInfo(array());

}

 

$languages = tep_get_languages();

 

$text_new_or_edit = ($HTTP_GET_VARS['action']=='new_category_ACD') ? TEXT_INFO_HEADING_NEW_CATEGORY : TEXT_INFO_HEADING_EDIT_CATEGORY;

?>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo sprintf($text_new_or_edit, tep_output_generated_category_path($current_category_id)); ?></td>

<td class="pageHeading" align="right"></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr><?php echo tep_draw_form('new_category', FILENAME_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=new_category_preview', 'post', 'enctype="multipart/form-data"'); ?>

<td><table border="0" cellspacing="0" cellpadding="2">

<?php

for ($i=0; $i<sizeof($languages); $i++) {

?>

<tr>

<td class="main"><?php if ($i == 0) echo TEXT_EDIT_XPAGECAT_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('xpagecat_name[' . $languages[$i]['id'] . ']', (($xpagecat_name[$languages[$i]['id']]) ? stripslashes($xpagecat_name[$languages[$i]['id']]) : tep_get_category_name2($cInfo->xpagecat_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; $i<sizeof($languages); $i++) {

?>

<tr>

<td class="main"><?php if ($i == 0) echo TEXT_EDIT_XPAGECAT_HEADING_TITLE; ?></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('xpagecat_heading_title[' . $languages[$i]['id'] . ']', (($xpagecat_name[$languages[$i]['id']]) ? stripslashes($xpagecat_name[$languages[$i]['id']]) : tep_get_category_heading_title($cInfo->xpagecat_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; $i<sizeof($languages); $i++) {

?>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_XPAGECAT_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 tep_draw_fckeditor('xpagecat_description[' . $languages[$i]['id'] . ']','700','300',(isset($xpagecat_description[$languages[$i]['id']]) ? $xpagecat_description[$languages[$i]['id']] : tep_get_category_description($cInfo->xpagecat_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<tr>

<td class="main"><?php echo TEXT_EDIT_XPAGECAT_IMAGE; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_file_field('xpagecat_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . $cInfo->xpagecat_image . tep_draw_hidden_field('xpagecat_previous_image', $cInfo->xpagecat_image); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_EDIT_SORT_ORDER; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" align="right"><?php echo tep_draw_hidden_field('xpagecat_date_added', (($cInfo->date_added) ? $cInfo->date_added : date('Y-m-d'))) . tep_draw_hidden_field('parent_id', $cInfo->parent_id) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '??<a href="' . tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

</form></tr>

<?php

 

//----- new_category_preview (active when ALLOW_CATEGORY_DESCRIPTIONS is 'true') -----

} elseif ($HTTP_GET_VARS['action'] == 'new_category_preview') {

if ($HTTP_POST_VARS) {

$cInfo = new objectInfo($HTTP_POST_VARS);

$xpagecat_name = $HTTP_POST_VARS['xpagecat_name'];

$xpagecat_heading_title = $HTTP_POST_VARS['xpagecat_heading_title'];

$xpagecat_description = $HTTP_POST_VARS['xpagecat_description'];

 

// copy image only if modified

$xpagecat_image = new upload('xpagecat_image');

$xpagecat_image->set_destination(DIR_FS_CATALOG_IMAGES);

if ($xpagecat_image->parse() && $xpagecat_image->save()) {

$xpagecat_image_name = $xpagecat_image->filename;

} else {

$xpagecat_image_name = $HTTP_POST_VARS['xpagecat_previous_image'];

}

# if ( ($xpagecat_image != 'none') && ($xpagecat_image != '') ) {

# $image_location = DIR_FS_CATALOG_IMAGES . $xpagecat_image_name;

# if (file_exists($image_location)) @unlink($image_location);

# copy($xpagecat_image, $image_location);

# } else {

# $xpagecat_image_name = $HTTP_POST_VARS['xpagecat_previous_image'];

# }

} else {

$category_query = tep_db_query("select c.xpagecat_id, cd.language_id, cd.xpagecat_name, cd.xpagecat_heading_title, cd.xpagecat_description, c.xpagecat_image, c.sort_order, c.date_added, c.last_modified from " . TABLE_XPAGECAT . " c, " . TABLE_XPAGECAT_DESCRIPTION . " cd where c.xpagecat_id = cd.xpagecat_id and c.xpagecat_id = '" . $HTTP_GET_VARS['cID'] . "'");

$category = tep_db_fetch_array($category_query);

 

$cInfo = new objectInfo($category);

$xpagecat_image_name = $cInfo->xpagecat_image;

}

 

$form_action = ($HTTP_GET_VARS['cID']) ? 'update_category' : 'insert_category';

 

echo tep_draw_form($form_action, FILENAME_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');

 

$languages = tep_get_languages();

for ($i=0; $i<sizeof($languages); $i++) {

if ($HTTP_GET_VARS['read'] == 'only') {

$cInfo->xpagecat_name = tep_get_category_name2($cInfo->xpagecat_id, $languages[$i]['id']);

$cInfo->xpagecat_heading_title = tep_get_category_heading_title($cInfo->xpagecat_id, $languages[$i]['id']);

$cInfo->xpagecat_description = tep_get_category_description($cInfo->xpagecat_id, $languages[$i]['id']);

} else {

$cInfo->xpagecat_name = tep_db_prepare_input($xpagecat_name[$languages[$i]['id']]);

$cInfo->xpagecat_heading_title = tep_db_prepare_input($xpagecat_heading_title[$languages[$i]['id']]);

$cInfo->xpagecat_description = tep_db_prepare_input($xpagecat_description[$languages[$i]['id']]);

}

?>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '?' . $cInfo->xpagecat_heading_title; ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $xpagecat_image_name, $cInfo->xpagecat_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $cInfo->xpagecat_description; ?></td>

</tr>

 

<?php

}

if ($HTTP_GET_VARS['read'] == 'only') {

if ($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_XPAGECAT;

$back_url_params = 'cPath=' . $cPath . '&cID=' . $cInfo->xpagecat_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)));

}

}

$languages = tep_get_languages();

for ($i=0; $i<sizeof($languages); $i++) {

echo tep_draw_hidden_field('xpagecat_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($xpagecat_name[$languages[$i]['id']])));

echo tep_draw_hidden_field('xpagecat_heading_title[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($xpagecat_heading_title[$languages[$i]['id']])));

echo tep_draw_hidden_field('xpagecat_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($xpagecat_description[$languages[$i]['id']])));

}

echo tep_draw_hidden_field('X_xpagecat_image', stripslashes($xpagecat_image_name));

echo tep_draw_hidden_field('xpagecat_image', stripslashes($xpagecat_image_name));

 

echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '??';

 

if ($HTTP_GET_VARS['cID']) {

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_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';

?></td>

</form></tr>

<?php

}

 

} else {

?>

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading">

<?php echo HEADING_TITLE; ?>

</td>

<td class="pageHeading" align="right">

</td>

<td align="right">

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<?php echo tep_draw_form('search', FILENAME_XPAGECAT, '', 'get'); ?>

<td class="smallText" align="right">

<?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search', $HTTP_GET_VARS['search']); ?>

</td></form>

</tr>

<tr>

<?php echo tep_draw_form('goto', FILENAME_XPAGECAT, '', 'get'); ?>

<td class="smallText" align="right">

<?php echo HEADING_TITLE_GOTO . ' ' . tep_draw_pull_down_menu('cPath', tep_get_category_tree2(), $current_category_id, 'onChange="this.form.submit();"'); ?>

</td></form>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<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_XPAGECAT; ?>

</td>

<td class="dataTableHeadingContent" align="center">

<?php echo TABLE_HEADING_STATUS; ?>

</td>

<td class="dataTableHeadingContent" align="right">

<?php echo TABLE_HEADING_ACTION; ?>

?</td>

</tr>

<?php

$xpagecat_count = 0;

$rows = 0;

if ($HTTP_GET_VARS['search']) {

$xpagecat_query = tep_db_query("select c.xpagecat_id, cd.xpagecat_name, c.xpagecat_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.xpagecat_status from " . TABLE_XPAGECAT . " c, " . TABLE_XPAGECAT_DESCRIPTION . " cd where c.xpagecat_id = cd.xpagecat_id and cd.language_id = '" . $languages_id . "' and cd.xpagecat_name like '%" . $HTTP_GET_VARS['search'] . "%' order by c.sort_order, cd.xpagecat_name");

} else {

$xpagecat_query = tep_db_query("select c.xpagecat_id, cd.xpagecat_name, c.xpagecat_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.xpagecat_status from " . TABLE_XPAGECAT . " c, " . TABLE_XPAGECAT_DESCRIPTION . " cd where c.parent_id = '" . $current_category_id . "' and c.xpagecat_id = cd.xpagecat_id and cd.language_id = '" . $languages_id . "' order by c.sort_order, cd.xpagecat_name");

}

while ($xpagecat = tep_db_fetch_array($xpagecat_query)) {

$xpagecat_count++;

$rows++;

 

// Get parent_id for subxpagecat if search

if ($HTTP_GET_VARS['search']) $cPath= $xpagecat['parent_id'];

 

if ( ((!$HTTP_GET_VARS['cID']) && (!$HTTP_GET_VARS['pID']) || (@$HTTP_GET_VARS['cID'] == $xpagecat['xpagecat_id'])) && (!$cInfo) && (substr($HTTP_GET_VARS['action'], 0, 4) != 'new_') ) {

$category_childs = array('childs_count' => tep_childs_in_category_count($xpagecat['xpagecat_id']));

 

$cInfo_array = array_merge($xpagecat, $category_childs);

$cInfo = new objectInfo($cInfo_array);

}

 

if ( (is_object($cInfo)) && ($xpagecat['xpagecat_id'] == $cInfo->xpagecat_id) ) {

echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_XPAGECAT, tep_get_path($xpagecat['xpagecat_id'])) . '\'">' . "\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_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $xpagecat['xpagecat_id']) . '\'">' . "\n";

}

?>

<td class="dataTableContent">

<?php echo '<a href="' . tep_href_link(FILENAME_XPAGECAT, tep_get_path($xpagecat['xpagecat_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>?<b>' . $xpagecat['xpagecat_name'] . '</b>'; ?>

</td>

 

<!-- // ################" Added Categories Disable #############

<td class="dataTableContent" align="center">?</td>

-->

<td class="dataTableContent" align="center">

<?php

if ($xpagecat['xpagecat_status'] == '1') {

echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '??<a href="' . tep_href_link(FILENAME_XPAGECAT, 'action=setflag_cat&flag=0&cID=' . $xpagecat['xpagecat_id'] . '&cPath=' . $cPath) . '">' . 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_XPAGECAT, 'action=setflag_cat&flag=1&cID=' . $xpagecat['xpagecat_id'] . '&cPath=' . $cPath) . '">' . 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>

<!-- // ################" End Added Categories Disable ############# -->

 

<td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($xpagecat['xpagecat_id'] == $cInfo->xpagecat_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $cPath . '&cID=' . $xpagecat['xpagecat_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?></td>

</tr>

<?php

}

?>

<td class="dataTableContent"></td>

<td class="dataTableContent" align="center">

</td>

<td class="dataTableContent" align="right"></td>

</tr>

 

<tr>

<td colspan="3">

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="smallText">

<?php echo TEXT_XPAGECAT . '?' . $xpagecat_count; ?>

</td>

<td align="right" class="smallText">

<?php if ($cPath) echo '<a href="' . tep_href_link(FILENAME_XPAGECAT, $cPath_back . '&cID=' . $current_category_id) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>?'; if (!$HTTP_GET_VARS['search']) echo '<a href="' . tep_href_link(FILENAME_XPAGECAT, 'cPath=' . $cPath . '&action=new_category') . '">' . tep_image_button('button_new_page.gif', TEXT_NEW_XPAGECAT) . '</a>'; ?>

?</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

<?php

$heading = array();

$contents = array();

switch ($HTTP_GET_VARS['action']) {

case 'new_category':

$heading[] = array&

Link to comment
Share on other sites

maybe this is reversed

 

Try

 

// make url link instead 
if( tep_not_null($foo[$xpage_counter]['url']) ) {
$xpagecat_string .= $foo[$xpage_counter]['url'];
} else {
$xpagecat_string .= tep_href_link(FILENAME_DEFAULTXPAGE, $cXpagePath_new);
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...