这里是我的需要; 我想在laravel php框架工作中包括不同视图的不同视图。如何在Laravel PHP框架中将控制器方法的视图作为另一个控制器视图的一部分包含进去
class DashboardController extends BaseController {
public function comments($level_1=''){
// process data according to $lavel_1
return View::make('dashboard.comments', $array_of_all_comments);
}
public function replys($level_2=''){
// process data according to $lavel_1
return View::make('dashboard.replys', $array_of_all_replys);
}
这两个数据现在可以从
www.abc.com/dashboard/comments
www.abc.com/dashboard/replys
在我看来,访问我需要的是根据评论ID($ lavel_2)
// dashboard/comments.blade.php
@extends('layout.main')
@section('content')
@foreach($array_of_all_comments as $comment)
comment {{ $comment->data }},
//here is what i need to load reply according to the current data;
//need to do something like this below
@include('dashboard.replys', $comment->lavel_2) //<--just for demo
.................
@stop
,并在生成回信回复也得到了
@extends('layout.main')
@section('content')
// dashboard/replys.blade.php
@foreach($array_of_all_replys as $reply)
You got a reply {{ $reply->data }},
...........
@stop
有没有什么办法可以在laravel 4上实现这一点?
请帮助我,我想加载两个意见和重放一气呵成,后来需要通过AJAX单独访问他们也
请帮帮我非常感谢你提前
我不能强调如何哈克和坏的做法,这是。您正在利用刀片标签的解析引擎来执行HMVC,Laravel的设计目的是不需要(大部分)。在视图中创建一个新的控制器(并创建'n'个新的控制器,其中'n'是'$ array_of_all_comments的大小],不应该出于任何原因 – Joe 2014-09-04 11:02:21