I read a thinkphp classification method, using a string to upload to the template

Source: Internet
Author: User
I want a thinkphp classification method, using a string to upload to the template
Public Function _getmenu ($id =0, $t =0) {
$category = M ("category");
$data = $category->where ("pid= $id")->order ("sort ASC")->select ();

if ($data) {
$t + +;
$data 2[' leavel ') = $t;
$category->where ("pid= $id")->save ($data 2);//Hierarchy
foreach ($data as $key = = $value) {
$sort = $value [' sort '];
$id = $value [' id '];
$this->str. = '';
$this->str. = "". $value [' id ']. "";
if ($t >1) {
if ()
$this->str. = "|-----". $value [' name ']. "";

}else{
$this->str. = "". $value [' name ']. "";
}
$this->str. = "". $value [' group ']. "";
$id = $value [' id '];
$this->str. = ' delete ';
$this->_getmenu ($value [' id '], $t);
}

}
}

------Solution--------------------
Then you have to judge whether all the columns under the current parent class are equal to the position of this column (the first few), and if they are equal, the last one will satisfy your request.
------Solution--------------------
The categorical array is $data
End ($DATA);
$ek = key ($data); The key value in the $data after a classification

Join in the Loop
if ($key = = $ek) $this->str. = "
------Solution--------------------
____ ". $value [' name ']."";
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.