Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP + Symfony] Menu ze slugami i dynamiczny routing
dopelganger
post
Post #1





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

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


cześć
nie wiem jak zrobić aby tworzyły się dynamiczne linki w menu ze slugiem (np: /o-firmie), kiedy je odczytuje to mam dziwną postać w źródle: web/app_dev.php/%7B%24slug%7D?slug=o-firmie

a kiedy klikam taki link to wywala błąd:
Controller "FrontBundle\Controller\DefaultController::pageAction()" requires that you provide a value for the "$slug" argument (because there is no default value or because there is a non optional argument after this one).


Builder.php

  1. $menu->addChild($c->getLabel(), array(
  2. 'route' => 'page',
  3. 'routeParameters' => array('slug' => $c->getLink())
  4. ));


DefaultController.php

  1. /**
  2.   * @Route("/{$slug}", name="page")
  3.   * @Template("FrontBundle:Page:page.html.twig")
  4.   */
  5. public function pageAction($slug)
  6. {
  7. return array();
  8. }


Prosze o pomoc

Ten post edytował dopelganger 21.06.2016, 13:01:44
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Turson
post
Post #2





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

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


{slug} a nie {$slug} w route
Go to the top of the page
+Quote Post
dopelganger
post
Post #3





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

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


Cytat(Turson @ 21.06.2016, 14:12:12 ) *
{slug} a nie {$slug} w route


coś się zaczyna dziać (IMG:style_emoticons/default/smile.gif)
wywala kolejnego byka:

An exception has been thrown during the rendering of a template ("Parameter "slug" for route "page" must match "[^/]++" ("" given) to generate a corresponding URL.") in FrontBundle:Default:index.html.twig at line 26.

Ten post edytował dopelganger 21.06.2016, 13:16:49
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 5.10.2025 - 15:05