【发布时间】:2019-05-06 18:44:54
【问题描述】:
我正在使用一个名为 chatter 的包,并设法将它包含在我自己的帖子中。 现在我有一个表叫games,每次创建一个新游戏时,我也会添加一个聊天讨论。这行得通。
因此,在单个游戏页面上,我将游戏的详细信息和聊天讨论加载为 iframe。这意味着现在我在 HTML 中有一个 HTML。 用户现在可以使用聊天讨论。
控制器看起来很像这样:
public function show(Game $game)
{
// We know this is a game
// Get the category first
$category = DB::table('chatter_categories')->whereName('Game')->first();
// Get the discussion
// A discussion has many post(s)
$discussion = DB::table('chatter_discussion')->whereChatterCategoryId($category->id)->first();
//dd($chatter_post);
return view('games.games', ['game' => $game, 'discussion' => $discussion, 'category' => $category]);
}
现在,在我的 games.blade 中,我有以下内容:
<article id="discussion">
<iframe id="myiframe" src="/forums/discussion/{{ $category->slug }}/{{ $discussion->slug }}" style="height: 800px; width: 100%;" frameborder="0" />
</article>
Chatter 默认页面带有一个标题,如下图所示:
如果我查看我创建的游戏,我还会看到有关该游戏的聊天讨论,如预期的那样:
问题:如何仅在游戏页面上删除聊天讨论的标题部分?
如果我只是直接针对标头 id
div#chatter_header{
display: none;
}
它会删除标题,但如果我访问 chatter 原始前端视图,它也会消失。
这是我想检查当前页面 URL 和相应样式的时候,但这不起作用。
我的游戏路线如下所示:
Route::resource('games', 'GameController');
【问题讨论】:
-
你的路线定义是什么?
-
路线定义会有更多帮助。
-
试试这个 {{ Request::segment(1) }} // 1 是 URL 参数位置。您可以更改此 2 或其他任何内容。
-
您的问题似乎是错误的,因为您要求的是一个参数,但实际上您的意思是一个路径段(根据您提供的 url 判断)。
标签: javascript php jquery laravel