witam

Uzywam symfony 1.2.4 a zatem i propela 1.3 i chcialem zkozystac z nested tree do generowanie kategorii na stronie i mam problem z tym:(

obecnie mam w bazie taka strukture (wzorujac sie na przykladach ze strony propela):

id | name | lft | rgt | scope |
1 | Top | 1 | 6 | 1 |
2 | komputery | 2 | 3 | 2 |
3 | Monitory | 4 | 5 | 2|

w akcji mam

  1. <?php
  2. $root = CategoriesPeer::retrieveTree(1);
  3. $this->it=new myMenuOutput($root);
  4. ?>


gdzie klasa myMenuOutput jest postaci:

  1. <?php
  2. class myMenuOutput extends RecursiveIteratorIterator {
  3.  function __construct(Menu $m) {
  4.    parent::__construct($m, self::SELF_FIRST);
  5.  }
  6.  
  7.  function beginChildren() {
  8.    echo str_repeat("\t", $this->getDepth());
  9.  }
  10.  
  11.  function endChildren() {
  12.    echo str_repeat("\t", $this->getDepth() - 1);
  13.  }
  14. }
  15. ?>


Czyli dokladnie tak jak w przykladach na stronie propela.

W widoku chce wyswietlic wszystkie kategorie i podkategorie:
  1. <?php print_r($it); ?>
  2. <ul>
  3.    <li><a href="">.::Kategorie::.</a></li>
  4.    <?php foreach($it as $m): ?>
  5.      <?php echo $m->getName(); ?>
  6.    <?php endforeach; ?>
  7.   <br />
  8.  </ul>


I tu pojawia sie problem. Mianowicie wyswietlana jest tylko glowna kategoria "TOP". Czy kto juz walczym z tym zaganieniem w nowym symfony?? Prosze o pomoc.


Udalo mi sie rozwiazac problem. Temat zamkniety.

Oto poprawne dane:

Blad w scope.

id | name | lft | rgt | scope |
1 | Top | 1 | 6 | 1 |
2 | komputery | 2 | 3 | 1 |
3 | Monitory | 4 | 5 | 1|

oraz

  1. <?php
  2. class myMenuOutput extends RecursiveIteratorIterator {
  3.  function __construct(Categories $m) {
  4.    parent::__construct($m, self::SELF_FIRST);
  5.  }
  6.  
  7.  function beginChildren() {
  8.    echo str_repeat("\t", $this->getDepth());
  9.  }
  10.  
  11.  function endChildren() {
  12.    echo str_repeat("\t", $this->getDepth() - 1);
  13.  }
  14. }
  15. ?>


Bledny type przekazywanego parametru do konstruktora.