I have the following situation. I have a model A with the following properties: id int name varchar (255) parent_id int (refers to the same model A).
Now I need to display the Tree View using ModelA. Of course, I could just load all the data, sort it correctly by parent_id and “render” using the traditional string binding. eg.
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();
now I would instead like to use my own liker / smlite atk4 template analyzer for this purpose. but, if you try to do this, then you will have an unpleasant lister, where in the format line you still try to substitute a specific tag at the output of another lister, which in fact you will have to destroy to fill the void memory.
any suggestions?
ps the code above is not tested, just shows the concept
thanks!
source share