snowbird
Administrator
      
Mesajlar: 721
Katılma Tarihi: Jul 2008
Rep Puanı: 6
|
Kategori resmini silme butonu eklemek
Benim anladığım kategori resmini iptal etmek ise bu kategori düzenle bölümüne buton ekleyip kategori resmini silmemizi sağlar
Şu 3 dosyayı değiştireceğiz
PHP Kod:
catalog/admin/categories.php catalog/admin/includes/languages/turkish/categories.php (varsa diğer diller) catalog/admin/includes/functions/general.php
catalog/admin/categories.php
_____________________________
Aşağıdakini bulalım
PHP Kod:
case 'delete_category_confirm': if (isset($HTTP_POST_VARS['categories_id'])) { $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
$categories = tep_get_category_tree($categories_id, '', '0', '', true); $products = array(); $products_delete = array();
for ($i=0, $n=sizeof($categories); $i<$n; $i++) { $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");
while ($product_ids = tep_db_fetch_array($product_ids_query)) { $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; } }
reset($products); while (list($key, $value) = each($products)) { $category_ids = '';
for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) { $category_ids .= "'" . (int)$value['categories'][$i] . "', "; } $category_ids = substr($category_ids, 0, -2);
$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")"); $check = tep_db_fetch_array($check_query); if ($check['total'] < '1') { $products_delete[$key] = $key; } }
// removing categories can be a lengthy process tep_set_time_limit(0); for ($i=0, $n=sizeof($categories); $i<$n; $i++) { tep_remove_category($categories[$i]['id']); }
reset($products_delete); while (list($key) = each($products_delete)) { tep_remove_product($key); } }
if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); }
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); break;
Hemen altın şunu ekleyelim:
PHP Kod:
case 'delete_category_image_confirm': if (isset($HTTP_POST_VARS['categories_id'])) { $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); tep_remove_category_image($categories_id);
}
if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); }
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); break;
Aşağıdakini bualım
PHP Kod:
case 'delete_category': $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CATEGORY . '</b>');
$contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO); $contents[] = array('text' => '<br><b>' . $cInfo->categories_name . '</b>'); if ($cInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count)); if ($cInfo->products_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count)); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break;
aşağıdakini altına ekleyelim:
PHP Kod:
case 'delete_category_image': $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CATEGORY_IMAGE . '</b>'); $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_image_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); $contents[] = array('text' => TEXT_DELETE_CATEGORY_IMAGE_INTRO); $contents[] = array('text' => '<br><b>' . $cInfo->categories_name . '</b>'); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete_image.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
Aşağıdakini bulalım
PHP Kod:
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=edit_category') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=move_category') . gory_image') . '">' . tep_image_button('button_delete_image.gif', IMAGE_DELETE) . '</a>');
aşağıdaki ile değiştirelim:
PHP Kod:
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=edit_category') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=move_category') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category_image') . '">' . tep_image_button('button_delete_image.gif', IMAGE_DELETE) . '</a>');
Aşağıdakini bulalım
PHP Kod:
contents[] = array('text' => '<br>' . tep_info_image($cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br>' . $cInfo->categories_image);
Altın şunu ekleyelim
PHP Kod:
if ($cInfo->categories_image) $contents[] = array('text' =>'<br><a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $category_path_string . '&cID=' . $cInfo->categories_id . '&action=delete_category_image') . '">' . tep_image_button('button_delete_image.gif', IMAGE_DELETE) . '</a>');
________________________________________________________________________________ ______________
catalog/admin/includes/languages/turkish/categories.php
________________________________________________________________________________ ______________
aşağıdaki tanımları ekleyelim:
PHP Kod:
define('TEXT_INFO_HEADING_DELETE_CATEGORY_IMAGE', 'Kategori resmini sil'); define('TEXT_DELETE_CATEGORY_IMAGE_INTRO', 'Kategori resmi silinecek emin misiniz?');
________________________________________________________________________________ ______________
catalog/admin/includes/functions/general.php
________________________________________________________________________________ ______________
aşağıdakini bulalım
PHP Kod:
function tep_remove_category($category_id) { $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); $category_image = tep_db_fetch_array($category_image_query);
$duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'"); $duplicate_image = tep_db_fetch_array($duplicate_image_query);
if ($duplicate_image['total'] < 2) { if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) { @unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']); } }
tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } }
Hemen altına şunu ekleyelim:
PHP Kod:
function tep_remove_category_image($category_id) { $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); $category_image = tep_db_fetch_array($category_image_query);
$duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'"); $duplicate_image = tep_db_fetch_array($duplicate_image_query);
if ($duplicate_image['total'] < 2) { if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) { unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']); } }
tep_db_query("update " . TABLE_CATEGORIES . " set categories_image ='' where categories_id = '" . (int)$category_id . "'");
if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } }
Son olarak
button_delete_image.gif" butonu oluşturup /catalog/admin/includes/languages/[DİL]/images/buttons altına koyunuz
Bundan sonra kategori düzenleye girdiğimizde bir buton çıkacak ve kat. resmini silmemizi sağlayacak
|
|