我正在使用一个名为chatter的包,并设法将其包含在我自己的帖子中。 现在我有一个名为 games 的表,每次创建新游戏时,我还会添加一个喋喋不休的讨论。这有效。
因此,在单个游戏页面上,我将游戏的详细信息和聊天讨论加载为 iframe。这意味着现在我在 HTML 中包含了 HTML。 用户现在可以使用聊天讨论。
Controller 看起来非常像这样:
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 默认页面带有标题,如下图所示:
如果我查看自己创建的游戏,我还会按预期看到该游戏的聊天讨论:
问题:如何删除仅在游戏页面上的聊天讨论的标题部分?
如果我只是直接定位 header ID
div#chatter_header{
display: none;
}
它将删除标题,但如果我访问chatter原始前端 View ,标题也会消失。
此时我想到检查当前页面 URL 和相应的样式,但这不起作用。
我的游戏路线如下:
Route::resource('games', 'GameController');
最佳答案
如果你使用 Laravel,你可以使用 URL 查询参数来做到这一点:
if ($request->has('forums')) {
// do stuff here
}
参见https://laravel.com/docs/5.7/requests#retrieving-input
在您的模板中,您可以使用:
@if(app('request')->input('forums'))
<span>Do stuff</span>
@endif
关于javascript - 有没有办法用 php 检查 url 中的特定参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53628213/