Laravelのページングシステムには、URLスニペットをページングリンクに取り付けることができる強力なfragment()
メソッドが含まれています。この機能は、ナビゲーション中にページの特定の部分にユーザーを誘導する場合に特に役立ちます。
fragment()
メソッドは、Laravelのページングシステムとシームレスに統合されています:
$users = User::paginate(15)->fragment('users');
#users
複数のコンテンツパーツまたは複雑なナビゲーション構造を扱う場合、
fragment()
laravelは、リンクのページングでフラグメントインクルージョンを自動的に処理し、
class ContentController extends Controller { public function index(Request $request) { $activeSection = $request->section ?? 'recent'; return View::make('content.index', [ 'posts' => Post::latest() ->paginate(10) ->fragment("section-{$activeSection}"), 'activeSection' => $activeSection ]); } } // views/content/index.blade.php <div id="section-{{ $activeSection }}"> @foreach ($posts as $post) @endforeach {{ $posts->links() }} </div>
以上がLaravel&#039;のページネーションにURLフラグメントを組み込んでいますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。