Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Kohana]Headers Css
PiotrekM
post 11.08.2011, 18:40:37
Post #1





Grupa: Zarejestrowani
Postów: 130
Pomógł: 6
Dołączył: 20.12.2009

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


Mam dziwny problem, gdyż nie mogę wysłać nagłówków.

  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3.  * Everything is a page
  4.  * Everything inside is a module
  5.  */
  6.  
  7. class Controller_File extends Controller
  8. {
  9. const TEMPLATE_PATH = 'application/templates/';
  10. public function action_index()
  11. {
  12. //get path
  13. $template_file = ORM::factory('templatefile') -> where('name', '=', $this -> request -> param('name')) -> find();
  14.  
  15. $this->request->headers('Content-Type', 'text/css');
  16.  
  17. echo $template_file -> content;
  18. }
  19.  
  20. } // End Welcome


to mój controller... próbowałem też tradycyjnym sposobem i nic...
kod wypluwa w plain texcie

pierwszy raz się z czymś takim spotykam... może to wina nowej kohany 3.2?

edit: to wina kohany, bo w osobnym pliku jest ok. co zrobić?

Ten post edytował PiotrekM 11.08.2011, 18:44:24
Go to the top of the page
+Quote Post
skowron-line
post 11.08.2011, 18:50:59
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


Próbowałeś
  1. $this->request->send_headers();


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
PiotrekM
post 11.08.2011, 20:04:27
Post #3





Grupa: Zarejestrowani
Postów: 130
Pomógł: 6
Dołączył: 20.12.2009

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


desperacko próbowałem, choć wiedziałem, że to tylko w KO3.0 a nie w 3.2
edit: wygląda to na BUG... zrobiłem tak: wysłałem header tradycyjnie tj. header('Content-type: text/css'); i nie wyechowałem kodu tylko umartwiłem smile.gif
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3.  * Everything is a page
  4.  * Everything inside is a module
  5.  */
  6.  
  7. class Controller_File extends Controller
  8. {
  9. const TEMPLATE_PATH = 'application/templates/';
  10.  
  11. public function action_index()
  12. {
  13. //get path
  14. $template_file = ORM::factory('templatefile') -> where('name', '=', $this -> request -> param('name')) -> find();
  15.  
  16. header('Content-type: text/css');
  17. die($template_file -> content);
  18. }
  19.  
  20. } // End Welcome


Ten post edytował PiotrekM 11.08.2011, 20:45:21
Go to the top of the page
+Quote Post
skowron-line
post 12.08.2011, 09:13:23
Post #4





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3.  * Everything is a page
  4.  * Everything inside is a module
  5.  */
  6.  
  7. class Controller_File extends Controller
  8. {
  9. const TEMPLATE_PATH = 'application/templates/';
  10. public function action_index()
  11. {
  12. //get path
  13. $template_file = ORM::factory('templatefile') -> where('name', '=', $this -> request -> param('name')) -> find();
  14.  
  15. $this->response->headers('Content-Type', 'text/css');
  16.  
  17. echo $template_file -> content;
  18. }
  19.  
  20. } // End Welcome
tak powinno zadziałać działa

Ten post edytował skowron-line 12.08.2011, 09:26:02


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
Kedan
post 23.08.2011, 12:08:53
Post #5





Grupa: Zarejestrowani
Postów: 53
Pomógł: 1
Dołączył: 20.07.2007

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


Możesz też przez
  1. $template_file->render();


Ponieważ dziedziczysz po klasie Controller a nie po Controller_Template automatyczne renderowanie jest 'wyłączone' więc wszystkie widoki musisz wyświetlać ręcznie. W Controller_Template masz zmienną $auto_render domyślnie ustawioną na TRUE - jeśli w danej akcji nie jest Ci potrzebna to ustawiasz na false i tyle...
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: 18.07.2025 - 05:55