Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework]Problem z routingiem
MaciekPierwszy
post 6.05.2013, 22:31:21
Post #1





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 8.02.2013

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


Witam

Dodałem sobie parametr języka w bootstrapie w następujący sposób

  1. $router->addRoute(
  2. 'lang',
  3. new Zend_Controller_Router_Route('/:lang/',
  4. array('lang' => ':lang')
  5. )
  6. );


Niestety z jakis nieznanych mi powodow nie wypisuje mi wtedy action w formularzach a robie to tak
  1. $url = $view->url(array(
  2. 'controller' => 'auth', 'action' => 'register'
  3. ));
  4. $this->setAction($url);


dlaczego tak się dzieje??
Go to the top of the page
+Quote Post
irmidjusz
post 6.05.2013, 22:48:33
Post #2





Grupa: Zarejestrowani
Postów: 279
Pomógł: 60
Dołączył: 25.02.2012

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


otwierasz dokumentację Zend_View_Helper_url i czytasz:

Generates an url given the name of a route.

return: Url for the link href attribute.
access: public

string url ([ $urlOptions = array()], [mixed $name = null], [bool $reset = false], [ $encode = true])

array $urlOptions: Options passed to the assemble method of the Route object.
mixed $name: The name of a Route to use. If null it will use the current Route
bool $reset: Whether or not to reset the route defaults with those provided
$encode


podpowiedź: drugi parametr to nazwa route


--------------------
there is much to be learned
Go to the top of the page
+Quote Post
MaciekPierwszy
post 8.05.2013, 18:40:05
Post #3





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 8.02.2013

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


mam teraz taki problem że przestał mi działac link typu

/profile/show/id/1
poniewaz zend tak to zaczął traktowac

Request Parameters:

array (
'lang' => 'profile',
'module' => 'show',
'controller' => 'id',
'action' => '1',
)


wszystko działa jak dodam w bootstrapie:
  1. $router->addRoute(
  2. 'controlleraction',
  3. new Zend_Controller_Router_Route('/:controller/:action/id/:id'
  4.  
  5. )
  6. );


ale jak zrobic zeby działała zawsze reguła
controller/action/zmienna1/wartosc1/zmienna2/wartosc2/ i tak dalej??
Go to the top of the page
+Quote Post
CuteOne
post 8.05.2013, 21:20:57
Post #4





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


Zend sam w sobie (bez żadnych ustawień) definiuje ścieżki. To co pokazałeś to właśnie taka ścieżka - /controller/action/param1/value1

Usuń wszystko co jest związane z routerem. Następnie w pliku .phtml dodaj np.
  1. echo $this->url(array(
  2. 'controller' => 'index',
  3. 'action' => 'index',
  4. 'lang' => 'pl'), null, true);

I sprawdź co wygeneruje, powinno się wyświetlić '/index/index/lang/pl'

Ten post edytował CuteOne 8.05.2013, 21:22:04
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: 24.04.2024 - 08:32