Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [CakePHP]problem z komponentem
Forum PHP.pl > Forum > PHP
Luzak
Mam problem z tworzeniem komponentu , a dokladnie ma być to menu , które bedzie pobierać z mysql informacje na temat kategorii i je wyswietlać.


app\controllers\components:
  1. <?php
  2. class MenuComponent extends Object {
  3. var $controller = true;
  4.  
  5. /**
  6.  * Startup method
  7.  * Called automatically, used to set the variable to define the menu.
  8.  * Could equally be used to define a context menu, based upon the controller nam
    e and action.
  9.  *
  10.  * @return null
  11.  */
  12. function startup(&$controller)
  13. {
  14. $this->controller = &$controller;
  15. $this->controller->set('MenuItems',$this->controller->Category->findAll());
  16. }
  17.  
  18. /**
  19.  * Check groups
  20.  * Perform any logic desired to delete groups.
  21.  * In this code, if a group is defined which is not a link and has no children i
    t is removed 
  22.  *
  23.  * @param array $menu
  24.  * @return array
  25.  */
  26.  
  27. }
  28. ?>


oraz stworzyłem model do obslugi kategorii
app\models:
  1. <?php
  2.  
  3. class Category extends AppModel
  4. {
  5. var $name = 'Category';
  6. }
  7.  
  8. ?>


Problem polega na tym , że nie wiem jak dostać się do tego modelu od strony komponentu questionmark.gif
bela
Mozesz utworzyc (new Category) albo przypisac w komponencie ($this->Category = &$this->controller->Category)
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.