jeudi 20 août 2015

include view based on href parameter in Laravel 5

Maybe a basic problem, but - lets say there is a dropdown menu with several submenus:

<a href="{{ URL::route('news') }}">News</a>
<a href="{{ URL::route('articles') }}">Articles</a>

linked to different views:

(news.blade.php, articles.blade.php ...)

The index.blade.php looks like this:

@extends('layouts.master')
@section('board')
    @include('files.index')
@endsection

Routes look like this:

<?php
Route::get('/', [
    'as' => 'home',
    'uses' => 'PagesController@home'
]);

Route::get('/articles', [
    'as' => 'articles',
    'uses' => 'PagesController@articles'
]);

Route::get('/news', [
    'as' => 'news',
    'uses' => 'PagesController@news'
]);

and the controller:

class PagesController extends Controller
{   
    public function home()
    {
       return view('files.index');
}

    public function articles()
    {
        return view('files.articles');
    }

    public function news()
    {
        return view('files.news');
    }
}

The problem is, that the 'board' section should load index.blade only at the beginning, but replace its content after a link from the menu is clicked. Thanks for any help.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TZ0lw4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire