Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [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
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ć 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
adbacz
post
Post #4





Grupa: Zarejestrowani
Postów: 532
Pomógł: 24
Dołączył: 15.04.2011
Skąd: Kalisz

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


Jak byk jest napisane, że podany pusty ciąg znaków, który nie pasuje do wzorca "[^/]++" parametru "slug". Gdzieś renderujesz w widoku ten adres i nie podałeś tego parametru.
Go to the top of the page
+Quote Post
dopelganger
post
Post #5





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

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


Cytat(adbacz @ 21.06.2016, 14:26:15 ) *
Jak byk jest napisane, że podany pusty ciąg znaków, który nie pasuje do wzorca "[^/]++" parametru "slug". Gdzieś renderujesz w widoku ten adres i nie podałeś tego parametru.


to ja wiem smile.gif
ok nieważne, na stronie głównej zrobiłem wyjątek dla pustego sluga w Entity i rozwiązało problem.
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 Aktualny czas: 20.08.2025 - 10:40