欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP的Laravel框架中使用AdminLTE模板來編寫網(wǎng)站后臺界面

 更新時間:2016年03月21日 17:43:10   作者:stoneworld  
這篇文章主要介紹了PHP的Laravel框架中使用AdminLTE模板來編寫網(wǎng)站后臺的方法,AdminLTE基于BootStrap,能幫助快速創(chuàng)建網(wǎng)站后臺管理面板界面,需要的朋友可以參考下

AdminLTE 是一個基于Bootstrap 3.x的免費高級管理控制面板主題,完全響應(yīng)式管理,適合從小型移動設(shè)備到大型臺式機很多的屏幕分辨率。

AdminLTE的特點:

  • 充分響應(yīng)
  • 可分類的儀表盤
  • 18插件和3自定義插件
  • 重量輕和快速
  • 與大多數(shù)主流瀏覽器兼容
  • 完全支持Glyphicons,Fontawesome和圖標

我們使用的工具

  • Laravel
  • AdminLTE 2.3.2
  • Bower
  • Composer

下載一個全新的 Laravel
如果不太清楚可以去官方網(wǎng)站查看文檔link
在此我們直接使用命令行即可

composer create-project laravel/laravel myapp --prefer-dist

   
通過這個命令我們創(chuàng)建了一個全新的名字為 myapp 的Laravel項目,如果你成功的話你可以看到下面的圖片

2016321173918278.png (800×498)

通過 Bower 下載 AdminLTE
進入到 myapp/public 文件夾

 
 cd myapp/public

在這個文件夾下執(zhí)行下面的命令

 bower install admin-lte

    
   
一旦完成,你會發(fā)現(xiàn)多了一個 bower_componets 的文件夾,而且在這個文件夾中你會看到 AdminLTE

將 AdminLTE 的starter.html 轉(zhuǎn)化為 Blade 模板
Laravel 在此使用了一個很好的模板引擎 Blade,為了更充分的利用Blade,我們需要將一些常規(guī)的通用的 HTML 的 起始頁面應(yīng)用到 Blade 模板中,首先創(chuàng)建一個 view 在 resources/views文件夾中,命名為admin_template.blade.php,而后我們?yōu)檫@個頁面創(chuàng)建一個對應(yīng)的路由。如下面我所創(chuàng)建的

    

 Route::get('admin', function () {
  return view('admin_template');
 });

然后,將bower_components/admin-lte/starter.html中的內(nèi)容復制到我們視圖模板中,并且將其中的相關(guān)鏈接指向我們的 AdminLTE 的對應(yīng)目錄下,如下是我初步的設(shè)置:

<script src="{{ asset("/bower_components/AdminLTE/plugins/jQuery/jQuery-2.1.4.min.js")}}"></script>
<!-- Bootstrap 3.3.5 -->
<script src="{{ asset("/bower_components/AdminLTE/bootstrap/js/bootstrap.min.js")}}"></script>
<!-- AdminLTE App -->
<script src="{{ asset("/bower_components/AdminLTE/dist/js/app.min.js")}}"></script>

類似這樣,將css 和 js 的相關(guān)的鏈接指向相應(yīng)的目錄下,而后我們通過 localhost:8000/admin 查看頁面的變化,此時頁面變成了如下圖:

2016321174005589.jpg (800×472)

現(xiàn)在我們擁有了所有的使用 AdminLTE 的所有的資源,下面對我們的主要視圖增加最后的收尾工作,我將分開這個模板為三個文件,sidebar.blade.php, header.blade.php, 和 footer.blade.php
這三個文件的內(nèi)容分別是admin_template.blade.phpheader 部分和 aside 部分和footer 部分,將這三部分截取出來依次放到三個文件中。

最后的潤色工作
現(xiàn)在我們已經(jīng)將我們的模板個性化的分離開了,下面我們需要設(shè)置我們的最初的admin_template.blade.php
模板以便于內(nèi)容動態(tài)加載,如下所示:

<!DOCTYPE html>
<html>
head>
<meta charset="UTF-8">
<title>{{ $page_title or "AdminLTE Dashboard" }}</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- Bootstrap 3.3.2 -->
<link href="{{ asset("/bower_components/AdminLTE/bootstrap/css/bootstrap.min.css") }}" rel="stylesheet" type="text/css" />
<!-- Font Awesome Icons -->
<link  rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link  rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="{{ asset("/bower_components/AdminLTE/dist/css/AdminLTE.min.css")}}" rel="stylesheet" type="text/css" />
<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
  page. However, you can choose any other skin. Make sure you
  apply the skin class to the body tag so the changes take effect.
-->
<link href="{{ asset("/bower_components/AdminLTE/dist/css/skins/skin-blue.min.css")}}" rel="stylesheet" type="text/css" />

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<!-- Header -->
@include('header')

<!-- Sidebar -->
@include('sidebar')

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
 <!-- Content Header (Page header) -->
 <section class="content-header">
  <h1>
   {{ $page_title or "Page Title" }}
   <small>{{ $page_description or null }}</small>
  </h1>
  <!-- You can dynamically generate breadcrumbs here -->
  <ol class="breadcrumb">
   <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
   <li class="active">Here</li>
  </ol>
 </section>

 <!-- Main content -->
 <section class="content">
  <!-- Your Page Content Here -->
  @yield('content')
 </section><!-- /.content -->
</div><!-- /.content-wrapper -->

<!-- Footer -->
@include('footer')
<aside class="control-sidebar control-sidebar-dark">
<!-- Create the tabs -->
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
 <li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
 <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
 <!-- Home tab content -->
 <div class="tab-pane active" id="control-sidebar-home-tab">
 <h3 class="control-sidebar-heading">Recent Activity</h3>
 <ul class="control-sidebar-menu">
  <li>
  <a href="javascript::;">
   <i class="menu-icon fa fa-birthday-cake bg-red"></i>

   <div class="menu-info">
   <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

   <p>Will be 23 on April 24th</p>
   </div>
  </a>
  </li>
 </ul>
 <!-- /.control-sidebar-menu -->

 <h3 class="control-sidebar-heading">Tasks Progress</h3>
 <ul class="control-sidebar-menu">
  <li>
  <a href="javascript::;">
   <h4 class="control-sidebar-subheading">
   Custom Template Design
   <span class="label label-danger pull-right">70%</span>
   </h4>

   <div class="progress progress-xxs">
   <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
   </div>
  </a>
  </li>
 </ul>
 <!-- /.control-sidebar-menu -->

 </div>
 <!-- /.tab-pane -->
 <!-- Stats tab content -->
 <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
 <!-- /.tab-pane -->
 <!-- Settings tab content -->
 <div class="tab-pane" id="control-sidebar-settings-tab">
 <form method="post">
  <h3 class="control-sidebar-heading">General Settings</h3>

  <div class="form-group">
  <label class="control-sidebar-subheading">
   Report panel usage
   <input type="checkbox" class="pull-right" checked>
  </label>

  <p>
   Some information about this general settings option
  </p>
  </div>
  <!-- /.form-group -->
 </form>
 </div>
 <!-- /.tab-pane -->
</div>
</aside>
<!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
 immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.1.3 -->
<script src="{{ asset ("/bower_components/AdminLTE/plugins/jQuery/jQuery-2.1.3.min.js") }}"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="{{ asset ("/bower_components/AdminLTE/bootstrap/js/bootstrap.min.js") }}" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="{{ asset ("/bower_components/AdminLTE/dist/js/app.min.js") }}" type="text/javascript"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
 Both of these plugins are recommended to enhance the
 user experience -->
</body>
</html>

在上面代碼中,我們添加了contetn,這里包含著我們的主要的內(nèi)容,增加了頁面標題針對不同的頁面,將其重命名為dashboard.blade.php現(xiàn)在這個模板已經(jīng)可以使用了。

測試頁面

為了驗證我們之前所做的工作,我將創(chuàng)建一個簡單的頁面

1.創(chuàng)建 test.blade.php

@extends('dashboard')
@section('content')
<div class='row'>
 <div class='col-md-6'>
  <!-- Box -->
  <div class="box box-primary">
   <div class="box-header with-border">
    <h3 class="box-title">Randomly Generated Tasks</h3>
    <div class="box-tools pull-right">
     <button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"><i class="fa fa-minus"></i></button>
     <button class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"><i class="fa fa-times"></i></button>
    </div>
   </div>
   <div class="box-body">
    @foreach($tasks as $task)
     <h5>
      {{ $task['name'] }}
      <small class="label label-{{$task['color']}} pull-right">{{$task['progress']}}%</small>
     </h5>
     <div class="progress progress-xxs">
      <div class="progress-bar progress-bar-{{$task['color']}}" style="width: {{$task['progress']}}%"></div>
     </div>
    @endforeach

   </div><!-- /.box-body -->
   <div class="box-footer">
    <form action='#'>
     <input type='text' placeholder='New task' class='form-control input-sm' />
    </form>
   </div><!-- /.box-footer-->
  </div><!-- /.box -->
 </div><!-- /.col -->
 <div class='col-md-6'>
  <!-- Box -->
  <div class="box box-primary">
   <div class="box-header with-border">
    <h3 class="box-title">Second Box</h3>
    <div class="box-tools pull-right">
     <button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"><i class="fa fa-minus"></i></button>
     <button class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"><i class="fa fa-times"></i></button>
    </div>
   </div>
   <div class="box-body">
    A separate section to add any kind of widget. Feel free
    to explore all of AdminLTE widgets by visiting the demo page
    on <a >Almsaeed Studio</a>.
   </div><!-- /.box-body -->
  </div><!-- /.box -->
 </div><!-- /.col -->

</div><!-- /.row -->
@endsection


2.創(chuàng)建TestController.php

php artisan make:controller TestController --plain

下面是這個控制器的代碼部分:    

 <?php

  namespace App\Http\Controllers;

  use Illuminate\Http\Request;
  use App\Http\Requests;
  use App\Http\Controllers\Controller;

  class TestController extends Controller
  {
   public function index() {
   $data['tasks'] = [
     [
      'name' => 'Design New Dashboard',
      'progress' => '87',
      'color' => 'danger'
     ],
     [
      'name' => 'Create Home Page',
      'progress' => '76',
      'color' => 'warning'
     ],
     [
      'name' => 'Some Other Task',
      'progress' => '32',
      'color' => 'success'
     ],
     [
      'name' => 'Start Building Website',
      'progress' => '56',
      'color' => 'info'
     ],
     [
      'name' => 'Develop an Awesome Algorithm',
      'progress' => '10',
      'color' => 'success'
     ]
   ];
   return view('test')->with($data);
  }

 }

3.創(chuàng)建對應(yīng)的路由

 Route::get('test', 'TestController@index');

4.打開對應(yīng)的頁面,如果你沒有出錯的 應(yīng)該如下圖所示

2016321174155654.jpg (800×472)

相關(guān)文章

  • 使PHP自定義函數(shù)返回多個值

    使PHP自定義函數(shù)返回多個值

    使PHP自定義函數(shù)返回多個值...
    2006-11-11
  • 為何說PHP引用是個坑,要慎用

    為何說PHP引用是個坑,要慎用

    在PHP 中引用的意思是用不同的名字訪問同一個變量內(nèi)容。與在C語言中的指針不同:例如不能對引用做指針運算,引用并不是實際的內(nèi)存地址。下面這篇文章主要給大家介紹了關(guān)于為何說PHP引用是個坑,要慎用的相關(guān)資料,需要的朋友可以參考下。
    2018-04-04
  • PHP調(diào)用Twitter的RSS的實現(xiàn)代碼

    PHP調(diào)用Twitter的RSS的實現(xiàn)代碼

    “守望軒”博客右側(cè)邊欄原來有個“雜感”的欄目,用來記錄短的、不能大篇幅成文的短句,或者自己比較喜歡的短句和言論。
    2010-03-03
  • php 數(shù)組隨機取值的簡單實例

    php 數(shù)組隨機取值的簡單實例

    下面小編就為大家?guī)硪黄猵hp 數(shù)組隨機取值的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-05-05
  • Uncaught exception com_exception with message Failed to create COM object

    Uncaught exception com_exception with message Failed to crea

    Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `InternetExplorer.Application': 拒絕訪問
    2012-01-01
  • PHP的instanceof詳解及使用方法介紹

    PHP的instanceof詳解及使用方法介紹

    php的instanceof是什么意思?instanceof由兩個單詞組成,instance和of,instance表示實例的意思,從字面上就可以理解這是實例引用的意思。instanceof?運算符是?PHP?5?引進的。在此之前用?is_a(),但是?is_a()?已經(jīng)過時了,最好用?instanceof。
    2023-05-05
  • php實現(xiàn)購物車功能(上)

    php實現(xiàn)購物車功能(上)

    這篇文章主要介紹了php實現(xiàn)購物車功能的全部代碼,提出了需求分析、解決方案、數(shù)據(jù)庫的創(chuàng)建,幫助大家輕輕松松實現(xiàn)購物車功能,感興趣的小伙伴們可以參考一下
    2016-01-01
  • PHP函數(shù)checkdnsrr用法詳解(Windows平臺用法)

    PHP函數(shù)checkdnsrr用法詳解(Windows平臺用法)

    這篇文章主要介紹了PHP函數(shù)checkdnsrr用法,分析講解了在Windows平臺使用checkdnsrr函數(shù)的方法,需要的朋友可以參考下
    2016-03-03
  • 解析php 版獲取重定向后的地址(代碼)

    解析php 版獲取重定向后的地址(代碼)

    本篇文章是對php版獲取重定向后的地址實現(xiàn)代碼進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • php中使用臨時表查詢數(shù)據(jù)的一個例子

    php中使用臨時表查詢數(shù)據(jù)的一個例子

    使用臨時表查詢數(shù)據(jù)的一個例子,供大家學習參考
    2013-02-02

最新評論