Navigation, highlight current page

后端 未结 7 1335
夕颜
夕颜 2020-12-14 09:15

I\'ve got a parent layout and derived from that child sites.

The parent layout has a navigation, each navigation point represents one child site.

How do i hi

7条回答
  •  暖寄归人
    2020-12-14 10:13

    in Silex, I do it like this:

    $app->before(function ($request) use ($app) {
        $app['twig']->addGlobal('active', $request->get("_route"));
    });
    

    Then in my Twig template file, {{ active }} equals to the current route.

    Simple and easy enough!

提交回复
热议问题