Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MVC] Widok i wyświetlanie danych
Asmox
post
Post #1





Grupa: Zarejestrowani
Postów: 359
Pomógł: 12
Dołączył: 16.01.2009

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


Otóż mam taki problem. Jest sobie klasa widoku HTML (w odróżnieniu od np. XML)
  1. class html
  2. {
  3. private $_templateSrc;
  4. private $_contents;
  5.  
  6. public function __construct($templateSrc, $contents) {
  7. $this->_templateSrc = $templateSrc;
  8. $this->_contents = $contents;
  9. }
  10.  
  11. public function insertCSS($src, $type=null) {
  12. if(empty($type)) $type = 'all';
  13. echo '<link href="'.$src.'" media="'.$type.'" rel="stylesheet" type="text/css">'."\n";
  14. }
  15.  
  16. public function insertJS($src) {
  17. echo '<script type="text/javascript" src="'.$src.'"> </script>'."\n";
  18. }
  19.  
  20. public function show() {
  21. Core::loadFile($this->_templateSrc);
  22. }
  23. }

I w szablonie jest coś takiego
  1. <?php $this->insertCSS(Core::DEFAULT_VIEWS_SRC . $this->_view . '/' . 'uklad.css'); ?>

Ale niestety to wywala błąd:
Cytat
Fatal error: Using $this when not in object context in [ścieżka]\views\html\templates\default\default.html on line 6

Czy da się to jakoś załatwić, żeby informacje były wyciągane bezpośrednio z widoku? Czyli innymi słowy, żeby nie było tego błędu i wszystko działało :-) ?


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 21.08.2025 - 19:22