2014-01-29 38 views
0

我最近開始使用Laravel框架,我想下面的(但似乎無法得到它的權利):Laravel - >路由分頁

  • 分頁,而不是其Laravel解釋,但更多的那種類型的/about.html - /portfolio.html等

這似乎真的很難做到這一點,我搜索了一下,找不到任何東西,也許我沒有使用正確的搜索條件。

HomeController提供包含所有html的佈局視圖。 缺省路由是:

Route::get('/', '[email protected]'); 

這是HomeControiler:

class HomeController extends BaseController { 

    public function show() { 
     return View::make('layout'); 
    } 

} 

回答

1

這不是分頁,它只是一個以上的路線。你對於路線會是這樣的:

Route::get('/', '[email protected]'); 
Route::get('/about', '[email protected]'); 
Route::get('/portfolio', '[email protected]'); 

相應的控制器可能是這樣:

class HomeController extends BaseController { 

    public function showIndex() { 
     return View::make('index'); 
    } 

    public function showAbout() { 
     return View::make('about'); 
    } 

    public function showPortfolio() { 
     return View::make('portfolio'); 
    } 

} 

你絕對不要把不同的路線HTML都在同一個視圖文件(共享導航應通過共享佈局和刀片關鍵字@extends進行處理),並且最好不要在路線完全沒有它的情況下使用.html擴展名。