Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [brand_id] => 233
                    [brand_name] => 谢池
                    [brand_logo] =>
                    [brand_desc] =>
                    [site_url] => http://
                    [sort_order] => 9
                    [is_show] => 1
                    [type_name] => 食品
                    [is_special] => 1
                    [cut_range] => 8
                    [cat_list] => Array
                        (
                            [0] => Array
                                (
                                    [cat_id] => 0
                                    [cat_name] => 所有分类
                                    [url] => brand.php?id=233
                                )                            [1] => Array
                                (
                                    [cat_id] => 116
                                    [cat_name] => 蜜饯
                                    [goods_count] => 72
                                    [url] => brand.php?id=233&cat=116
                                )                            [2] => Array
                                (
                                    [cat_id] => 119
                                    [cat_name] => 海产类
                                    [goods_count] => 7
                                    [url] => brand.php?id=233&cat=119
                                )                            [3] => Array
                                (
                                    [cat_id] => 120
                                    [cat_name] => 核果
                                    [goods_count] => 20
                                    [url] => brand.php?id=233&cat=120
                                )                            [4] => Array
                                (
                                    [cat_id] => 121
                                    [cat_name] => 瓜子
                                    [goods_count] => 8
                                    [url] => brand.php?id=233&cat=121
                                )                            [5] => Array
                                (
                                    [cat_id] => 122
                                    [cat_name] => 花生
                                    [goods_count] => 3
                                    [url] => brand.php?id=233&cat=122
                                )                            [6] => Array
                                (
                                    [cat_id] => 123
                                    [cat_name] => 豆类
                                    [goods_count] => 10
                                    [url] => brand.php?id=233&cat=123
                                )                            [7] => Array
                                (
                                    [cat_id] => 125
                                    [cat_name] => 薯条薯片
                                    [goods_count] => 1
                                    [url] => brand.php?id=233&cat=125
                                )                            [8] => Array
                                (
                                    [cat_id] => 126
                                    [cat_name] => 水果片
                                    [goods_count] => 3
                                    [url] => brand.php?id=233&cat=126
                                )                            [9] => Array
                                (
                                    [cat_id] => 148
                                    [cat_name] => 儿童饼干
                                    [goods_count] => 1
                                    [url] => brand.php?id=233&cat=148
                                )                            [10] => Array
                                (
                                    [cat_id] => 167
                                    [cat_name] => 软糖
                                    [goods_count] => 3
                                    [url] => brand.php?id=233&cat=167
                                )                            [11] => Array
                                (
                                    [cat_id] => 196
                                    [cat_name] => 茶
                                    [goods_count] => 1
                                    [url] => brand.php?id=233&cat=196
                                )                            [12] => Array
                                (
                                    [cat_id] => 431
                                    [cat_name] => 海苔
                                    [goods_count] => 5
                                    [url] => brand.php?id=233&cat=431
                                )                            [13] => Array
                                (
                                    [cat_id] => 435
                                    [cat_name] => 肉松
                                    [goods_count] => 2
                                    [url] => brand.php?id=233&cat=435
                                )                            [14] => Array
                                (
                                    [cat_id] => 436
                                    [cat_name] => 牛肉干
                                    [goods_count] => 4
                                    [url] => brand.php?id=233&cat=436
                                )                            [15] => Array
                                (
                                    [cat_id] => 438
                                    [cat_name] => 猪肉
                                    [goods_count] => 1
                                    [url] => brand.php?id=233&cat=438
                                )                        )                )            [1] => Array
                (
                    [brand_id] => 845
                    [brand_name] => 优の良品
                    [brand_logo] =>
                    [brand_desc] =>
                    [site_url] => http://
                    [sort_order] => 61
                    [is_show] => 1
                    [type_name] => 食品
                    [is_special] => 1
                    [cut_range] => 8.5
                    [cat_list] => Array
                        (
                            [0] => Array
                                (
                                    [cat_id] => 0
                                    [cat_name] => 所有分类
                                    [url] => brand.php?id=845
                                )                            [1] => Array
                                (
                                    [cat_id] => 457
                                    [cat_name] => 积分区
                                    [goods_count] => 4
                                    [url] => brand.php?id=845&cat=457
                                )                            [2] => Array
                                (
                                    [cat_id] => 468
                                    [cat_name] => 休闲小食
                                    [goods_count] => 11
                                    [url] => brand.php?id=845&cat=468
                                )                        )                )        )
)
这个是数组,
我在.dwt文件里是这么写的:复制代码   1.          <!-- {foreach from=$special_list item="specials" key=k} -->
   2.             <table width="100%" border="0" class="brand_tb1" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB">
   3.                 <tr>
   4.                     <td class="td1"><h1>{$specials[$k].brand_name} <samp style="color:#FF0000">{$specials.cut_range}</samp></h1></td>
   5.                 </tr>
   6.                 <tr>
   7.                     <td class="td2"><table width="0" border="0" cellspacing="0" cellpadding="5">
   8.                 <tr>
   9.                     <td valign="top"><!-- {if $specials.brand_logo} -->
  10.                         <p><a href="{$specials.site_url}" target="_blank"><img src="data/brandlogo/{$specials.brand_logo}" style="border:1px solid #ddd" /></a></p>
  11.                         <!-- {/if} --></td>
  12.                     <td valign="top"><p>
  13.                             <!-- {foreach from=$specials[0].cat_list item=cat} -->
  14.                             <span><a href="{$cat.url}">{$cat.cat_name|escape:html}</a></span>
  15.                             <!-- {/foreach} -->
  16.                     </p></td>
  17.                 </tr>
  18.             </table></td>
  19.                 </tr>
  20.             </table>
  21.         <!-- {/foreach} -->
$smarty->assign('special_list',get_special_brand());
为什么什么内容都不显示呢?
[/pre]

解决方案 »

  1.   

    你这边的数组外面还潜套个 array ,所以你还必须加个  foreach 你试试用我下面的代码 
    <!-- {foreach from=$special_list item=special key=ke} --> 
    <!-- {foreach from=$special item=specials key=k} --> 
                <table width="100%" border="0" class="brand_tb1" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> 
                    <tr> 
                        <td class="td1"> <h1>{$specials[$k].brand_name} <samp style="color:#FF0000">{$specials.cut_range} </samp> </h1> </td> 
                    </tr> 
                    <tr> 
                        <td class="td2"> <table width="0" border="0" cellspacing="0" cellpadding="5"> 
                    <tr> 
                        <td valign="top"> <!-- {if $specials.brand_logo} --> 
                            <p> <a href="{$specials.site_url}" target="_blank"> <img src="data/brandlogo/{$specials.brand_logo}" style="border:1px solid #ddd" /> </a> </p> 
                            <!-- {/if} --> </td> 
                        <td valign="top"> <p> 
                                <!-- {foreach from=$specials[0].cat_list item=cat} --> 
                                <span> <a href="{$cat.url}">{$cat.cat_name|escape:html} </a> </span> 
                                <!-- {/foreach} --> 
                        </p> </td> 
                    </tr> 
                </table> </td> 
                    </tr> 
                </table> 
            <!-- {/foreach} --> 
      <!-- {/foreach} --> 
      

  2.   

    或者直接循环 $special_list[0],或者外面再加一层foreach
     1.          <!-- {foreach from=$special_list[0] item="specials" key=k} --> 
      2.            <table width="100%" border="0" class="brand_tb1" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> 
      3.                <tr> 
      4.                    <td class="td1"> <h1>{$specials[$k].brand_name} <samp style="color:#FF0000">{$specials.cut_range} </samp> </h1> </td> 
      5.                </tr> 
      6.                <tr> 
      7.                    <td class="td2"> <table width="0" border="0" cellspacing="0" cellpadding="5"> 
      8.                <tr> 
      9.                    <td valign="top"> <!-- {if $specials.brand_logo} --> 
      10.                        <p> <a href="{$specials.site_url}" target="_blank"> <img src="data/brandlogo/{$specials.brand_logo}" style="border:1px solid #ddd" /> </a> </p> 
      11.                        <!-- {/if} --> </td> 
      12.                    <td valign="top"> <p> 
      13.                            <!-- {foreach from=$specials[0].cat_list item=cat} --> 
      14.                            <span> <a href="{$cat.url}">{$cat.cat_name|escape:html} </a> </span> 
      15.                            <!-- {/foreach} --> 
      16.                    </p> </td> 
      17.                </tr> 
      18.            </table> </td> 
      19.                </tr> 
      20.            </table> 
      21.        <!-- {/foreach} --> 
      

  3.   


    {foreach from=$special_list item="specials_f"}
    {foreach from=$specials_f item="specials" key="k"}
    <table width="100%" border="0" class="brand_tb1" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> 
    <tr> 
    <td class="td1"><h1>{$specials.brand_name}<samp style="color:#FF0000">{$specials.cut_range}</samp></h1></td> 
    </tr> 
    <tr> 
    <td class="td2">
    <table width="0" border="0" cellspacing="0" cellpadding="5"> 
    <tr> 
    <td valign="top"> 
    {if $specials.brand_logo}
    <p><a href="{$specials.site_url}" target="_blank"><img src="data/brandlogo/{$specials.brand_logo}" style="border:1px solid #ddd" /> </a> </p> 
    {/if}
    </td> 
    <td valign="top"> 
    <p> 
    {foreach from=$specials.cat_list item=cat}
    <span><a href="{$cat.url}">{$cat.cat_name|escape:html} </a> </span> 
    {/foreach}
    </p> 
    </td> 
    </tr> 
    </table> 
    </td> 
    </tr> 
    </table> 
    {/foreach}
    {/foreach}统一下就好了,不知道外面的那个是不是多余的
      

  4.   

    [align=left]或者你把数组 输出格式改成下面这样,模板不要动就可以: 
    Array 
    (     [0] => Array 
            ( 
                [brand_id] => 233 
                [brand_name] => 谢池 
                  [brand_logo] => 
                        [brand_desc] => 
                        [site_url] => http:// 
                        [sort_order] => 9 
                        [is_show] => 1 
                        [type_name] => 食品 
                        [is_special] => 1 
                        [cut_range] => 8 
                        [cat_list] => Array 
                            ( 
                                [0] => Array 
                                    ( 
                                        [cat_id] => 0 
                                        [cat_name] => 所有分类 
                                        [url] => brand.php?id=233 
                                    )                             [1] => Array 
                                    ( 
                                        [cat_id] => 116 
                                        [cat_name] => 蜜饯 
                                        [goods_count] => 72 
                                        [url] => brand.php?id=233&cat=116 
                                    )                             [2] => Array 
                                    ( 
                                        [cat_id] => 119 
                                        [cat_name] => 海产类 
                                        [goods_count] => 7 
                                        [url] => brand.php?id=233&cat=119 
                                    )                             [3] => Array 
                                    ( 
                                        [cat_id] => 120 
                                        [cat_name] => 核果 
                                        [goods_count] => 20 
                                        [url] => brand.php?id=233&cat=120 
                                    )                             [4] => Array 
                                    ( 
                                        [cat_id] => 121 
                                        [cat_name] => 瓜子 
                                        [goods_count] => 8 
                                        [url] => brand.php?id=233&cat=121 
                                    )                             [5] => Array 
                                    ( 
                                        [cat_id] => 122 
                                        [cat_name] => 花生 
                                        [goods_count] => 3 
                                        [url] => brand.php?id=233&cat=122 
                                    )                             [6] => Array 
                                    ( 
                                        [cat_id] => 123 
                                        [cat_name] => 豆类 
                                        [goods_count] => 10 
                                        [url] => brand.php?id=233&cat=123 
                                    )                             [7] => Array 
                                    ( 
                                        [cat_id] => 125 
                                        [cat_name] => 薯条薯片 
                                        [goods_count] => 1 
                                        [url] => brand.php?id=233&cat=125 
                                    )                             [8] => Array 
                                    ( 
                                        [cat_id] => 126 
                                        [cat_name] => 水果片 
                                        [goods_count] => 3 
                                        [url] => brand.php?id=233&cat=126 
                                    )                             [9] => Array 
                                    ( 
                                        [cat_id] => 148 
                                        [cat_name] => 儿童饼干 
                                        [goods_count] => 1 
                                        [url] => brand.php?id=233&cat=148 
                                    )                             [10] => Array 
                                    ( 
                                        [cat_id] => 167 
                                        [cat_name] => 软糖 
                                        [goods_count] => 3 
                                        [url] => brand.php?id=233&cat=167 
                                    )                             [11] => Array 
                                    ( 
                                        [cat_id] => 196 
                                        [cat_name] => 茶 
                                        [goods_count] => 1 
                                        [url] => brand.php?id=233&cat=196 
                                    )                             [12] => Array 
                                    ( 
                                        [cat_id] => 431 
                                        [cat_name] => 海苔 
                                        [goods_count] => 5 
                                        [url] => brand.php?id=233&cat=431 
                                    )                             [13] => Array 
                                    ( 
                                        [cat_id] => 435 
                                        [cat_name] => 肉松 
                                        [goods_count] => 2 
                                        [url] => brand.php?id=233&cat=435 
                                    )                             [14] => Array 
                                    ( 
                                        [cat_id] => 436 
                                        [cat_name] => 牛肉干 
                                        [goods_count] => 4 
                                        [url] => brand.php?id=233&cat=436 
                                    )                             [15] => Array 
                                    ( 
                                        [cat_id] => 438 
                                        [cat_name] => 猪肉 
                                        [goods_count] => 1 
                                        [url] => brand.php?id=233&cat=438 
                                    )                         )                 )             [1] => Array 
                    ( 
                        [brand_id] => 845 
                        [brand_name] => 优の良品 
                        [brand_logo] => 
                        [brand_desc] => 
                        [site_url] => http:// 
                        [sort_order] => 61 
                        [is_show] => 1 
                        [type_name] => 食品 
                        [is_special] => 1 
                        [cut_range] => 8.5 
                        [cat_list] => Array 
                            ( 
                                [0] => Array 
                                    ( 
                                        [cat_id] => 0 
                                        [cat_name] => 所有分类 
                                        [url] => brand.php?id=845 
                                    )                             [1] => Array 
                                    ( 
                                        [cat_id] => 457 
                                        [cat_name] => 积分区 
                                        [goods_count] => 4 
                                        [url] => brand.php?id=845&cat=457 
                                    )                             [2] => Array 
                                    ( 
                                        [cat_id] => 468 
                                        [cat_name] => 休闲小食 
                                        [goods_count] => 11 
                                        [url] => brand.php?id=845&cat=468 
                                    )                         )                 ) )