简体   繁体   中英

How to custom code in Laravel-5 from PHP

I want to transform this code for laravel blade template <?php echo ($page=="menu" ? "header-active" : "")?>

i have code in Php to make header menu.

<ul class = "menu-container">
        <li class="header-hover <?php echo ($page=="home" ? "header-active" : "")?>">
            <a href="{{URL::to('/')}}"><div class="menu">HOME</div></a>            </li>
        <li class="header-hover <?php echo ($page=="menu2" ? "header-active" : "")?>">
            <div class="menu">Menu 2</div>
            <ul class="in">
                <li><a href="{{URL::to('/menu2 A')}}">MENU 2A</div></a>            </li>
            </ul>
        </li>
    </ul>

Please Help me I get error : Undefined variable: page

Try the following -
{!!$page=="layanan" ? "header-active" : ""!!} {!!$page=="layanan" ? "header-active" : ""!!} .

Before that, make sure you have installed laravelcollective/html

If not, Follow the below steps,

  1. add "laravelcollective/html": "5.1.*" in the require feild inside composer.json file in the root of the project.
  2. Run composer update from root of your project. This will install the package required for blade templating by laravel.
  3. In config/app.php, under providers add Collective\\Html\\HtmlServiceProvider::class .
  4. In config/app.php, under aliases add 'Form'=>Collective\\Html\\FormFacade::class and 'Html'=>Collective\\Html\\HtmlFacade::class .

Thankyou :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM