小编CAM*_*CAM的帖子

使用Agile Toolkit进行递归树渲染

我有以下情况.我有一个具有以下属性的模型A:id int name varchar(255)parent_id int(引用相同的模型A).

现在,我需要使用ModelA渲染树视图.当然,我可以加载所有数据,通过parent_id正确排序,并使用传统的字符串粘贴"渲染".例如

class Model_A extends Model_Table {
...

function render_branch($nodes, $parent){
    if (!isset($nodes[$parent])){
        return null;
    }
    $out = "<ul>";
    foreach ($nodes[$parent] as $node){
        $out .= "<li>" . $node["name"];
        $out .= $this->render_branch($nodes, $node["id"]);
        $out .= "</li>";
    }
    return $out;
}

function init(){
    parent::init();
    $nodes = array(); // preload from db and arrange so that key = parent and content is array of childs
    $this->template->set("tree", $this->render_branch($nodes, 0));
}

}
Run Code Online (Sandbox Code Playgroud)

现在,我想改为使用atk4 native lister/smlite模板解析器.但是,如果你试图这样做,那么你最终会遇到讨厌的lister,在格式行中,你无论如何都会尝试用其他lister的输出替换特定标记,实际上你必须破坏运行时内存溢出.

有什么建议?

上面的ps代码没有经过测试,只是显示了概念

谢谢!

php recursion atk4

6
推荐指数
1
解决办法
844
查看次数

我有一个我想要实现的系统,建议或理论会非常酷

所以我想从预先构建的系统中提取内容......它使用PHP + MySQL来CRUD数据,我正在考虑在可登录用户可以设置的可移动+可拖动窗口中显示数据,并在之后调用登录.我正在考虑使用一些HTML5 + CSS3优点的cookie和AJAX,甚至是一些带有mongoDB的Cappucino.PLease LMK你们都在想什么.V/R CAM

database ajax user-interface html5 user-experience

2
推荐指数
1
解决办法
61
查看次数

标签 统计

ajax ×1

atk4 ×1

database ×1

html5 ×1

php ×1

recursion ×1

user-experience ×1

user-interface ×1