私は30k以上のカテゴリのショップを持っています。カテゴリの量に合わせてデザインされていない製品編集ページのカテゴリ選択を処理する方法は管理ではほとんど不可能です。非常に長く、時にはクラッシュすることもあります。それは単純な選択ボックスであり、何ができるのだろうか?カテゴリのphp出力
これが機能するには、ajaxが必要ですか?
<?php function custom_catalog_tree($category_id=0, $depth=1, $count=0) {
$output = '';
if ($category_id == 0) {
$output .= '<div class="checkbox" id="category-id-'. $category_id .'"><label>'. functions::form_draw_checkbox('categories[]', '0', (isset($_POST['categories']) && in_array('0', $_POST['categories'], true)) ? '0' : false, 'data-name="'. htmlspecialchars(language::translate('title_root', 'Root')) .'" data-priority="0"') .' '. functions::draw_fonticon('fa-folder', 'title="'. language::translate('title_root', 'Root') .'" style="color: #cccc66;"') .' ['. language::translate('title_root', 'Root') .']</label></div>' . PHP_EOL;
}
// Output categories
$categories_query = database::query(
"select c.id, ci.name
from ". DB_TABLE_CATEGORIES ." c
left join ". DB_TABLE_CATEGORIES_INFO ." ci on (ci.category_id = c.id and ci.language_code = '". language::$selected['code'] ."')
where c.parent_id = '". (int)$category_id ."'
order by c.priority asc, ci.name asc;"
);
while ($category = database::fetch($categories_query)) {
$count++;
$output .= ' <div class="checkbox"><label>'. functions::form_draw_checkbox('categories[]', $category['id'], true, 'data-name="'. htmlspecialchars($category['name']) .'" data-priority="'. $count .'"') .' '. functions::draw_fonticon('fa-folder fa-lg', 'style="color: #cccc66; margin-left: '. ($depth*1) .'em;"') .' '. $category['name'] .'</label></div>' . PHP_EOL;
if (database::num_rows(database::query("select * from ". DB_TABLE_CATEGORIES ." where parent_id = '". $category['id'] ."' limit 1;")) > 0) {
$output .= custom_catalog_tree($category['id'], $depth+1, $count);
}
}
database::free($categories_query);
return $output;
}
echo custom_catalog_tree();
?>
あなたが本当に選択ボックスで30Kオプションを表示する必要がありますか? – modsfabio
管理バックエンド用です。私はこの量のカテゴリーを持っていますし、はい、私は様々なカテゴリーに製品に付ける必要があります。 – medgalys
30k以上のカテゴリーのショップ...?それらをすべてより速く表示しようとするよりも、あなたのショップ/カテゴリーを再設計するべきだと思います。人間の脳は30kカテゴリを扱うことはできません。価値はありません。カテゴリについて本当に話しているのですか、タグのようなものについてもっと話していますか? – Twinfriends