After much research, I have found that Laravel is very nice. I have a homepage opening with an animation and after it the menu and page content splits into each side. With the links clicked, I only want content to change. I tried jQuery/ajax to work with. But I have a question, I want the links inside the content and sidebar-menu to change content. Can you show me the way to do that?
This is my ajax.js :
$(document).ready( function() {
$("#content ul li a").click( function(e){
e.preventDefault();
$('#page').load(this.href);
return false;
});
});
This is my Articles controller:
<?php
class Articles_Controller extends Base_Controller
{
public $restful = true;
public $layout = 'layouts.default';
public function get_index(){
$this->layout->title = "Anasayfa";
$this->layout->content = View::make('articles.index')
->with('articles',Article::order_by('id')->get());
}
public function get_view($id){
$this->layout->title = "Hizmetlerimiz";
$this->layout->content = View::make('articles.view')
->with('article',Article::find($id));
}
}
My default.blade.php
:
<div id="wrapper">
<div id="page">
{{ $content }}
</div>
<div id="sidebar">
<div id="sidebar-content">
<!-- MENU -->
<ul id="menu">
<li class="current"><a href="#">ANASAYFA</a></li>
<li><a href="#">HAKKIMIZDA</a></li>
// ...
My index.blade.php
:
<div id="content">
@foreach($articles as $article)
<ul class="blog-medium">
<li>
<div class="blog-medium-text">
<h1><a href="./post.html">{{$article-> title }} </a></h1>
<p class="blog-medium-excerpt"><p>Tek kişilik sınıflarda YGS - LYS hazırlık programımızda dersler özel…<br />
{{ HTML::link_to_route('article','devamı', array($article->id)) }}</p>
</div>
</li>
</ul>
@endforeach
</div>
My view.blade.php
:
<div id="content">
<h1>{{$article->title}}</h1>
<p>{{$article->content}}</p>
</div>