toArray();
$second_category = \app\backend\modules\goods\models\Category::getCategorySecondLevel()->toArray();
$third_category = \app\backend\modules\goods\models\Category::getCategoryThirdLevel()->toArray();
$html .= '
';
foreach ($first_category as $goodcate_parent) //一级分类
{
$href = yzAppFullUrl('catelist/' . $goodcate_parent['id']);
$html .= <<
{$goodcate_parent['name']}
EOF;
foreach ($second_category as $key => $value)
{
if ($value['parent_id'] == $goodcate_parent['id'])
{
$href = yzAppFullUrl('catelist/' . $value['id']);
$html .= <<
{$value['name']}
EOF;
foreach ($third_category as $k => $v) //三级分类
{
if ($v['parent_id'] == $value['id'])
{
$href = yzAppFullUrl('catelist/' . $v['id']);
$html .= <<
{$v['name']}
EOF;
}
}
}
}
}
$html .= '';
return $html;
});
}
public static function tplGoodsCategoryShow()
{
return Cache::remember('tpl:goods_category', 7200, function () {
$html = '';
$first_category = \app\backend\modules\goods\models\Category::getCategoryFirstLevel()->toArray();
$second_category = \app\backend\modules\goods\models\Category::getCategorySecondLevel()->toArray();
$third_category = \app\backend\modules\goods\models\Category::getCategoryThirdLevel()->toArray();
$html .= '';
foreach ($first_category as $goodcate_parent) {
$html .= <<
{$goodcate_parent['name']}
EOF;
foreach ($second_category as $value) {
if ($value['parent_id'] == $goodcate_parent['id'])
{
# code...
$html .= <<
{$value['name']}
EOF;
foreach ($third_category as $v)
{
if ($v['parent_id'] == $value['id'])
{
$html .= <<
{$v['name']}
EOF;
}
}
}
}
}
$html .= <<
EOF;
return $html;
});
}
}