• <tfoot id='EsyEY'></tfoot>
      <i id='EsyEY'><tr id='EsyEY'><dt id='EsyEY'><q id='EsyEY'><span id='EsyEY'><b id='EsyEY'><form id='EsyEY'><ins id='EsyEY'></ins><ul id='EsyEY'></ul><sub id='EsyEY'></sub></form><legend id='EsyEY'></legend><bdo id='EsyEY'><pre id='EsyEY'><center id='EsyEY'></center></pre></bdo></b><th id='EsyEY'></th></span></q></dt></tr></i><div id='EsyEY'><tfoot id='EsyEY'></tfoot><dl id='EsyEY'><fieldset id='EsyEY'></fieldset></dl></div>
      <legend id='EsyEY'><style id='EsyEY'><dir id='EsyEY'><q id='EsyEY'></q></dir></style></legend>

      • <bdo id='EsyEY'></bdo><ul id='EsyEY'></ul>

      1. <small id='EsyEY'></small><noframes id='EsyEY'>

        在 Laravel 中放置菜单逻辑的位置?

        Where to place menu logic in Laravel?(在 Laravel 中放置菜单逻辑的位置?)
        <i id='BMbSf'><tr id='BMbSf'><dt id='BMbSf'><q id='BMbSf'><span id='BMbSf'><b id='BMbSf'><form id='BMbSf'><ins id='BMbSf'></ins><ul id='BMbSf'></ul><sub id='BMbSf'></sub></form><legend id='BMbSf'></legend><bdo id='BMbSf'><pre id='BMbSf'><center id='BMbSf'></center></pre></bdo></b><th id='BMbSf'></th></span></q></dt></tr></i><div id='BMbSf'><tfoot id='BMbSf'></tfoot><dl id='BMbSf'><fieldset id='BMbSf'></fieldset></dl></div>

        <small id='BMbSf'></small><noframes id='BMbSf'>

      2. <tfoot id='BMbSf'></tfoot>
          <tbody id='BMbSf'></tbody>
        <legend id='BMbSf'><style id='BMbSf'><dir id='BMbSf'><q id='BMbSf'></q></dir></style></legend>

          • <bdo id='BMbSf'></bdo><ul id='BMbSf'></ul>

                • 本文介绍了在 Laravel 中放置菜单逻辑的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Laravel 中放置菜单数据逻辑的最佳概念位置是什么?如果我使用 Menu bundle 把它放在哪里.在 Base_Controller 中创建附加功能或不同的东西?

                  解决方案

                  注意:此答案是为 Laravel 3 编写的,可能适用于最新的 Laravel 4,也可能不适用

                  <小时>

                  我最喜欢的动态菜单创建方式是将菜单部分与主布局分离,并通过 Laravel 的 Composer 注入菜单数据(不要将其与 Composer PHP 包管理器混淆,它们是不同的东西)

                  <div id="header">标题</div><div id="菜单">@render('parts.menu')

                  <div id="内容"></div><div id="页脚"></div>

                   

                  <ul>@foreach($menuitems 作为 $menuitem)<li>{{ $menuitem->title }}</li>@endforeach

                   

                  最后我们可以通过 composer 注入变量.

                  with('menuitems', Menu::all());});

                  这样每次调用 parts/menu.blade.php 时,Composer 都会拦截视图并将其注入 $menuitems 变量.这与在 return View::make('blahblah')->with( 'menuitems', Menu::all() )

                  上使用 with 相同

                  希望有帮助:)

                  <小时>

                  编辑:如果你不喜欢在 routes.php 中有逻辑你可以把它放在 start.php 并考虑 JasonLewis 将 start.php 拆分成单独文件的方法.

                  application 中创建一个名为 start 的目录,并用一些文件填充它.

                   + 应用程序 [DIR]->+ 开始 [目录]|->自动加载.php|->作曲家.php|->过滤器.php->验证.php

                  然后将这些代码行添加到application/start.php

                  的末尾

                  需要 __DIR__ .DS.'开始' .DS.'自动加载.php';需要 __DIR__ .DS.'开始' .DS.'过滤器.php';需要 __DIR__ .DS.'开始' .DS.'作曲家.php';需要 __DIR__ .DS.'开始' .DS.'验证.php';

                  你明白了.将 Composer 函数放在 composers.php 中.

                  在此处阅读整篇文章:http://jasonlewis.me/article/laravel-使事情井井有条

                  What is best conceptual place to put menu data logic in Laravel. If I use Menu bundle where to put it. In Base_Controller create additional function or something different?

                  解决方案

                  Note: this answer was written for Laravel 3 and might or might not work with the most recent Laravel 4


                  My favorite way of creating dynamic menu is achieved by separating the menu part from main layout and injecting the menu data via Laravel's Composer (don't confuse it with Composer PHP package manager, they are different things)

                  <!-- layouts/default.blade.php -->
                  
                  <div id="header">Title</div>
                  
                  <div id="menu">
                      @render('parts.menu')
                  </div>
                  
                  <div id="content"></div>
                  <div id="footer"></div>
                  

                   

                  <!-- parts/menu.blade.php -->
                  
                  <ul>
                  @foreach($menuitems as $menuitem)
                      <li>{{ $menuitem->title }}</li>
                  @endforeach
                  </ul>
                  

                   

                  Finally we can inject the variable via composer.

                  <?php 
                  
                  // application/routes.php
                  
                  View::composer('parts.menu', function($view){
                      $view->with('menuitems', Menu::all());
                  });
                  

                  This way everytime parts/menu.blade.php is called, Composer will intercept the view and inject it with $menuitems variable. It's same as using with on return View::make('blahblah')->with( 'menuitems', Menu::all() )

                  Hope it helps :)


                  Edit: If you don't like to have logics in routes.php you can put it in start.php and consider Jason Lewis' way of splitting the start.php into separate files.

                  Create a directory in application called start and fill it with some files.

                      + application [DIR]
                      -> + start [DIR]
                          |-> autoloading.php
                          |-> composers.php
                          |-> filters.php
                          -> validation.php
                  

                  Then add these lines of code into the end of your application/start.php

                  require __DIR__ . DS . 'start' . DS . 'autoloading.php';
                  require __DIR__ . DS . 'start' . DS . 'filters.php';
                  require __DIR__ . DS . 'start' . DS . 'composers.php';
                  require __DIR__ . DS . 'start' . DS . 'validation.php';
                  

                  You got the idea. Put the composer functions in composers.php.

                  Read the entire article here: http://jasonlewis.me/article/laravel-keeping-things-organized

                  这篇关于在 Laravel 中放置菜单逻辑的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <i id='pzg78'><tr id='pzg78'><dt id='pzg78'><q id='pzg78'><span id='pzg78'><b id='pzg78'><form id='pzg78'><ins id='pzg78'></ins><ul id='pzg78'></ul><sub id='pzg78'></sub></form><legend id='pzg78'></legend><bdo id='pzg78'><pre id='pzg78'><center id='pzg78'></center></pre></bdo></b><th id='pzg78'></th></span></q></dt></tr></i><div id='pzg78'><tfoot id='pzg78'></tfoot><dl id='pzg78'><fieldset id='pzg78'></fieldset></dl></div>

                • <tfoot id='pzg78'></tfoot>
                    <tbody id='pzg78'></tbody>

                      <small id='pzg78'></small><noframes id='pzg78'>

                        <bdo id='pzg78'></bdo><ul id='pzg78'></ul>
                          <legend id='pzg78'><style id='pzg78'><dir id='pzg78'><q id='pzg78'></q></dir></style></legend>