このメッセージの下部に配列を生成しています。私はCodeIgniterとこの配列を使用して、次のビューを介して階層情報を表示しています。
<?php foreach($products['top_cats'] as $top_cat): // $top_cat ?>
<h2><?php echo $top_cat['cat_name']; ?></h2>
<?php if( ! empty($products['sub_cats'][$top_cat['cat_id']])): ?>
<?php foreach($products['sub_cats'][$top_cat['cat_id']] as $sub_cat): ?>
<h3><?php echo $sub_cat['name']; ?></h3>
<!-- problem below -->
<?php $this->load->view('products_table_v', $products[$sub_cat['id']][$n]); ?>
<?php var_dump($n); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
$products[top_cats][14]
に関連し$products[sub_cats][14]
、に$products[sub_cats][14]
関連し$products[products][14]
ます(これが理にかなっていることを願っています)。$products[products][14]
ですから、私がforeachにいるときは、ビューに渡す必要があります$products[sub_cats][14]
(繰り返しますが、これが理にかなっていることを願っていますか?)...
私の問題は、正しいsub-sub(-sub)配列をサブビュー(適切に機能するforeachループが含まれている)に渡す必要があることです。配列にサブビューを与える方法について頭を悩ませることはできません(コードブラインドになりました)。
助けてください。
Array
(
[top_cats] => Array
(
[14] => Array
(
[cat_id] => 14
[cat_name] => Alcopops
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] =>
[cat_sort_order] =>
[category_active] => y
)
[2] => Array
(
[cat_id] => 2
[cat_name] => Beers and Lagers
[cat_desc] => <p>hh</p>
[cat_featured] => n
[cat_parent_id] => 0
[cat_sort_order] =>
[category_active] => y
)
[79] => Array
(
[cat_id] => 79
[cat_name] => Household
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] =>
[cat_sort_order] =>
[category_active] => y
)
[5] => Array
(
[cat_id] => 5
[cat_name] => Soft Drinks
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] =>
[cat_sort_order] =>
[category_active] => y
)
[4] => Array
(
[cat_id] => 4
[cat_name] => Spirits
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] =>
[cat_sort_order] =>
[category_active] => y
)
[3] => Array
(
[cat_id] => 3
[cat_name] => Wines
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] =>
[cat_sort_order] =>
[category_active] => y
)
)
[sub_cats] => Array
(
[3] => Array
(
[25] => Array
(
[id] => 25
[name] => Champagne and Sparkling Wines
[desc] =>
[cat_parent_id] => 3
)
[22] => Array
(
[id] => 22
[name] => Australian Wines
[desc] =>
[cat_parent_id] => 3
)
)
[14] => Array
(
[30] => Array
(
[id] => 30
[name] => White Rum
[desc] =>
[cat_parent_id] => 4
)
[32] => Array
(
[id] => 32
[name] => Liquers
[desc] =>
[cat_parent_id] => 4
)
)
[2] => Array
(
[8] => Array
(
[id] => 8
[name] => Canned Lager
[desc] =>
[cat_parent_id] => 2
)
[12] => Array
(
[id] => 12
[name] => Bottled Beer
[desc] =>
[cat_parent_id] => 2
)
[10] => Array
(
[id] => 10
[name] => Bitter Cans
[desc] =>
[cat_parent_id] => 2
)
[7] => Array
(
[id] => 7
[name] => Super Beers
[desc] =>
[cat_parent_id] => 2
)
[13] => Array
(
[id] => 13
[name] => Cider
[desc] =>
[cat_parent_id] => 2
)
[9] => Array
(
[id] => 9
[name] => Stout
[desc] =>
[cat_parent_id] => 2
)
)
[] => Array
(
[5] => Array
(
[id] => 5
[name] => Soft Drinks
[desc] =>
[cat_parent_id] =>
)
[79] => Array
(
[id] => 79
[name] => Household
[desc] =>
[cat_parent_id] =>
)
[14] => Array
(
[id] => 14
[name] => Alcopops
[desc] =>
[cat_parent_id] =>
)
)
)
[products] => Array
(
[25] => Array
(
[1347] => Array
(
[product_id] => 1347
[category_id] => 25
[name] => Asti Spumante Martini
[description] =>
[source_price] => 29.00
[source_pack_size] => 6
[source_item_size] => 75.00
[source_unit_id] => 2
[resale_price] => 7.00
[resale_pack_size] => 1
[percentage_return] => 22.59
[product_code] => WNAS001
[product_image] => 1347_.jpg
[current_stock] => 5
[stock_level_id] => 0
[featured] => y
[active] => y
[so_member_of_group_id] => 0
[discount_amount] => 3.50
[created_at] => 2009-07-22 10:21:57
[modified_at] =>
[product_unit_id] => 2
[unit_name] => Centilitre
[unit_symbol] => cl
[stock_levels_id] =>
[stock_levels_name] =>
[cat_id] => 25
[cat_name] => Champagne and Sparkling Wines
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] => 3
[cat_sort_order] =>
[category_active] => y
)
[1566] => Array
(
[product_id] => 1566
[category_id] => 25
[name] => Blossom Hill Zinfandel Sparkling
[description] =>
[source_price] => 29.99
[source_pack_size] => 6
[source_item_size] => 70.00
[source_unit_id] => 2
[resale_price] => 8.49
[resale_pack_size] => 1
[percentage_return] => 29.35
[product_code] => WNBH010
[product_image] =>
[current_stock] => 30
[stock_level_id] =>
[featured] => n
[active] => y
[so_member_of_group_id] =>
[discount_amount] => 0.00
[created_at] => 2011-03-21 10:35:47
[modified_at] =>
[product_unit_id] => 2
[unit_name] => Centilitre
[unit_symbol] => cl
[stock_levels_id] =>
[stock_levels_name] =>
[cat_id] => 25
[cat_name] => Champagne and Sparkling Wines
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] => 3
[cat_sort_order] =>
[category_active] => y
)
)
[22] => Array
(
[1020] => Array
(
[product_id] => 1020
[category_id] => 22
[name] => Auction House Cabernet Sauvignon Merlot (Aus)
[description] =>
[source_price] => 20.00
[source_pack_size] => 6
[source_item_size] => 75.00
[source_unit_id] => 2
[resale_price] => 5.00
[resale_pack_size] => 1
[percentage_return] => 27.18
[product_code] => WNAH008
[product_image] => 1020_.jpg
[current_stock] => 35
[stock_level_id] => 0
[featured] => y
[active] => y
[so_member_of_group_id] => 0
[discount_amount] => 0.75
[created_at] => 2008-03-10 14:56:16
[modified_at] =>
[product_unit_id] => 2
[unit_name] => Centilitre
[unit_symbol] => cl
[stock_levels_id] =>
[stock_levels_name] =>
[cat_id] => 22
[cat_name] => Australian Wines
[cat_desc] =>
[cat_featured] => n
[cat_parent_id] => 3
[cat_sort_order] =>
[category_active] => y
)
)
)
)