2017-01-31 1 views
-2

내 컨트롤러에서이 코드는로드 내 첫 페이지 : 링크를 누르면심포니는 : 다른 페이지로 나뭇 가지에서 링크

<a href="{{ path('options') }}">My options</a> 

, 내가 원하는에 : 나는 my base.html.twig에 링크가

/** 
    * @Route("/main") 
    */ 
     public function indexAction() 
    { 
     $templating = $this->container->get('templating'); 
     $html = $templating->render('base.html.twig'); 

return new Response($html); 
    } 

@Route("/options")을 사용하고 내 옵션 페이지로 이동하십시오. 질문은 올바르게 수행하는 방법입니까? 고마워요.

/** 
    * @Route("/options") 
    */ 
    public function showAction(){ 

    return new Response("This will be options page:"); 
} 
+1

는 경로 이름을 추가

/** * @Route("/options", name="route-name") */ public function showAction() { return new Response("This will be options page:"); } 

지금 경로의 이름을 사용 SensioFrameworkExtraBundle/annotations/routing.html # route-name 또는 경로 기능에서 기본값 사용 – Cerad

답변

2

이 시도 : http://symfony.com/doc/current/bundles/ :

<a href="{{ path('route-name') }}">My options</a> 
관련 문제