Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] Zend_Router
UDAT
post 25.10.2006, 10:50:41
Post #1





Grupa: Zarejestrowani
Postów: 442
Pomógł: 0
Dołączył: 27.12.2005

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


Jak ustawić Zend_Router aby nie odnosił mi się do ROOT_DIR serwera.

Dałem plik .htaccess do katalogu ROOT_DIR/subdir
Mam też odpowiednią strukturę , ale ciągle odnosi się do ROOT'_DIRa.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Sabistik
post 25.10.2006, 12:39:22
Post #2


Administrator wortalu


Grupa: Przyjaciele php.pl
Postów: 960
Pomógł: 39
Dołączył: 21.10.2003
Skąd: Kraków

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


Sprawdź: http://www.akrabat.com/zend-framework-tutorial/
Go to the top of the page
+Quote Post
UDAT
post 27.10.2006, 19:00:37
Post #3





Grupa: Zarejestrowani
Postów: 442
Pomógł: 0
Dołączył: 27.12.2005

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


Dobra. Użyłem Zend_Controller_RewriteRouter i działa.

Ale można sobie go o kant d*** rozbić.

Kod
http://host/katalog/newsy/lista/page/3/category/7


jest nie wiadomo czemu rozkładana na jakieś dziwne rzeczy ( których siłą rzeczy nie ma ), zamiast zgodnie z tym co piszą w dokumentacji na kontroler -> NewsyController i akcję -> listaAction z parametrami.

Jak skonfigurować oprócz dodania po jednym wpisie dla jednej akcji ?

Ten post edytował UDAT 27.10.2006, 19:01:11
Go to the top of the page
+Quote Post
envp
post 27.10.2006, 20:37:24
Post #4





Grupa: Zarejestrowani
Postów: 359
Pomógł: 1
Dołączył: 16.04.2006
Skąd: Łódź

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


troche przerobiony (działający router zenda):

  1. <?php
  2. public function __construct()
  3. {
  4. $this->_sURI = $this->_formatQuery();
  5. }
  6.  
  7. private function _formatQuery(){
  8. return substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME'])-9,strlen($_SERVER['REQUEST_URI']));
  9. }
  10.  
  11. public function route()
  12. {
  13.  
  14. if (strstr($this->_sURI, '?')) {
  15. $this->_sURI = substr($this->_sURI, 0, strpos($this->_sURI, '?'));
  16. }
  17. $this->_aParams = explode('/', trim($this->_sURI, '/'));
  18. $this->_sCtrlName = $this->_aParams[0];
  19. $this->_sActName = isset($this->_aParams[1]) ? $this->_aParams[1] : null;
  20.  
  21. if (!strlen($this->_sCtrlName))
  22. {
  23. $this->_sCtrlName = _DEFAULT_CTRL_NAME;
  24. $this->_sActName = _DEFAULT_ACT_NAME;
  25. }
  26.  
  27.  
  28.  
  29.  $aActParams = array();
  30.  for ($i=2; $i<sizeof($this->_aParams); $i=$i+2) {
  31.  $aActParams[$this->_aParams[$i]] = isset($this->_aParams[$i+1]) ? $this->_aParams[$i+1] : null;
  32.  }
  33.  
  34.  
  35.  $oCurrentAction = new DispatcherToken($this->_sCtrlName, $this->_sActName, $aActParams);
  36.  
  37.  return $oCurrentAction;
  38.  
  39. }
  40. ?>
Go to the top of the page
+Quote Post
UDAT
post 28.10.2006, 10:11:42
Post #5





Grupa: Zarejestrowani
Postów: 442
Pomógł: 0
Dołączył: 27.12.2005

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


Cytat(envp @ 27.10.2006, 21:37:24 ) *
troche przerobiony (działający router zenda):

  1. <?php
  2. public function __construct()
  3. {
  4. $this->_sURI = $this->_formatQuery();
  5. }
  6.  
  7. private function _formatQuery(){
  8. return substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME'])-9,strlen($_SERVER['REQUEST_URI']));
  9. }
  10.  
  11. public function route()
  12. {
  13.  
  14. if (strstr($this->_sURI, '?')) {
  15. $this->_sURI = substr($this->_sURI, 0, strpos($this->_sURI, '?'));
  16. }
  17. $this->_aParams = explode('/', trim($this->_sURI, '/'));
  18. $this->_sCtrlName = $this->_aParams[0];
  19. $this->_sActName = isset($this->_aParams[1]) ? $this->_aParams[1] : null;
  20.  
  21. if (!strlen($this->_sCtrlName))
  22. {
  23. $this->_sCtrlName = _DEFAULT_CTRL_NAME;
  24. $this->_sActName = _DEFAULT_ACT_NAME;
  25. }
  26.  $aActParams = array();
  27.  for ($i=2; $i<sizeof($this->_aParams); $i=$i+2) {
  28.  $aActParams[$this->_aParams[$i]] = isset($this->_aParams[$i+1]) ? $this->_aParams[$i+1] : null;
  29.  }
  30.  $oCurrentAction = new DispatcherToken($this->_sCtrlName, $this->_sActName, $aActParams);
  31.  
  32.  return $oCurrentAction;
  33.  
  34. }
  35. ?>


Nie działa.

Choćby _DEFAULT_ACT_NAME i _DEFAULT_CTRL_NAME jest niezdefiniowane oraz metoda route nie jest zgodna z interfejsem.

Ten post edytował UDAT 28.10.2006, 10:12:11
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 - 02:25