{~W('Menu/cate')}

D:\LearnWebDevelop\php\thinkphp_3.2.3_full\Application\OuterMok2\View\Index\index2.html

<layout name="Layout/newlayout" />
<body>
{~W('Menu/index')}
<hr>
{~W('Menu/title',array(5,'thinkphp'))}
<hr>
{~W('Menu/cate')}
<hr>
<form method="post" action="">
    <input type="submit">
</form>
</body>
<?php
//D:\LearnWebDevelop\php\thinkphp_3.2.3_full\Application\OuterMok2\Widget\MenuWidget.class.php
namespace OuterMok2\Widget;
class MenuWidget extends \Think\Controller {
    
public function index(){
    echo 'menuWidget';
}

public function title($id,$name){
    echo $id.':'.$name;
}

public function cate(){
    $menu = M('Cate')->getField('id,title');
    //var_dump($menu);exit();
    /*
    array (size=10)
      1 => string 'qqq' (length=3)
      2 => string 'www' (length=3)
      3 => string 'rrr' (length=3)
      4 => string 'ttt' (length=3)
      5 => string 'yyy' (length=3)
      6 => string 'uuu' (length=3)
      7 => string 'iii' (length=3)
      8 => string 'ooo' (length=3)
      9 => string 'ppp' (length=3)
      10 => string 'aaa' (length=3)
    */
    $this->assign('menu',$menu);
    $this->display('Widget/menu');
}


}

D:\LearnWebDevelop\php\thinkphp_3.2.3_full\Application\OuterMok2\View\Widget\menu.html

<foreach name="menu" item="title">
{$key}:{$title}<br>
</foreach>

menuWidget


5:thinkphp


1:qqq
2:www
3:rrr
4:ttt
5:yyy
6:uuu
7:iii
8:ooo
9:ppp
10:aaa


posted @ 2017-12-18 14:50  sky20080101  阅读(177)  评论(0)    收藏  举报