Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> application:fetch() błąd kodu.
zmora_jlb
post 5.12.2013, 09:38:25
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 5.12.2013

Ostrzeżenie: (0%)
-----


Witam, postanowiłem dzisiaj stworzyć prosty model do przyszłej strony,
jednak nie mogę sobię poradzić z pewną rzeczą, a mianowicie:


  1. <?php
  2. class application
  3. {
  4. public $smarty;
  5. public $db;
  6.  
  7. public function __construct()
  8. {
  9. include_once('libs/smarty/Smarty.class.php');
  10. $smarty = new Smarty;
  11. }
  12.  
  13. public function render_page()
  14. {
  15. define('VIEW_DIR', 'views/');
  16.  
  17. $this->_module = $_GET[module]; // pobieramy katalog modulu
  18. $this->_file = $_GET[view]; // pobieramy plik
  19.  
  20. if(empty($this->_file)){
  21. $this->_file = $this->_module;
  22. }
  23.  
  24. $this->is_module = is_dir(VIEW_DIR.$this->_module);
  25. $this->is_module_tpl = file_exists(VIEW_DIR.$this->_module.'/'.$this->_file.'.tpl');
  26. $this->is_module_controller = file_exists(VIEW_DIR.$this->_module.'/'.$this->_file.'.php');
  27.  
  28. if($this->is_module==TRUE && $this->is_module_tpl == TRUE && $this->is_module_controller == TRUE){
  29.  
  30. // load module controller
  31. include_once(VIEW_DIR.$this->_module.'/'.$this->_file.'.php');
  32.  
  33. $output = new $this->_file;
  34. $output->init($smarty, $db);
  35.  
  36. // load module template
  37. smarty::display(VIEW_DIR.$this->_module.'/'.$this->_file.'.tpl');
  38.  
  39. } else {
  40. echo '<b>errors:</b><br />';
  41. echo 'is_module: '.$this->is_module.'<br />';
  42. echo 'is_module_tpl: '.$this->is_module_tpl.'<br />';
  43. echo 'is_module_controller: '.$this->is_module_controller.'<br />';
  44. }
  45.  
  46. }
  47. }
  48. ?>



błąd: Fatal error: Call to undefined method application::fetch() in /home/zeroszum/domains/[DOMENA]/public_html/projekty/kurs_angielskiego/libs/smarty/sysplugins/smarty_internal_templatebase.php on line 377


zależy mi na tym, aby $smarty było dostępne w całej klasie application i i podklasach.
proszę o jakąś podpowiedź smile.gif

Ten post edytował zmora_jlb 5.12.2013, 09:39:57
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Turson
post 5.12.2013, 09:53:54
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Najbardziej rzuca mi się w oczy
  1. $_GET[module]
  2. $_GET[view];
Go to the top of the page
+Quote Post
zmora_jlb
post 5.12.2013, 10:05:09
Post #3





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 5.12.2013

Ostrzeżenie: (0%)
-----


po problemie smile.gif użyję CodeIgniter
Go to the top of the page
+Quote Post
phpion
post 5.12.2013, 10:34:44
Post #4





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Nie:
  1. $smarty = new Smarty;

tylko:
  1. $this->smarty = new Smarty;

i później zamiast $smarty odwołujesz się przez $this->smarty.

Cytowany błąd mówi jasno: w klasie application nie ma metody fetch. We wklejonym kodzie jasno widać, że jej tam faktycznie nie ma.

// Przenoszę na przedszkole.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 02:00