Dropdown with indented categories in Agile Toolkit

I have a category table with id, name, id_parent structure. I’m using atk4 and I like to show dropdown with indented subcategories. So:

---cat3 etc

I did build something working however like to see how this can be improved. Currently I have recursive sql queries based on the hasMany(). It feels like this can be done without re-quering. And main worry is that I now have the styling defined in the model but I don’t know how to move out. I tried to learn myself controller functionality but didn’t manage so far. My code so far:

The model

class Model_Category extends Model_Table {
  public $table='category';
  function init() {

  function tree($prefix='') {
    foreach($childs as $child) {
    return $r;

On the page:

$m->load(1); // start recursive from home category

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>