Dynamic On Page Navigation
Dynamic On-page Navigation to load Previous and Next Pages
<div class="container" id="art_animation">
<div class="row">
<div class="col">
<hgroup><h2>{{$blog->title}}</h2>
<span>By
<a href="#">
{{getUserData($user_id,'name')}}
</a>
</span>
<span>In<a href="#">Blog</a></span><span class="text-secondary">{{date("l, F d, Y",strtotime($blog->created_at))}}</span></hgroup>
<p>{{strip_tags($blog->body)}}</p>
</div>
</div>
<hr>
<div id="navigate_pages">
<div id="box1">
<?php $id = $blog->id;
$first =App\BlogPost::oldest()->first();
if( $id == $first->id) {
echo "";
}
else {
$id--;
$blog_data = App\BlogPost::select('*')->where('id', $id)->first();
?>
<a href="{{ URL::to('blog/'.$blog_data->slug) }}" class="color_maroon">PREVIOUS</a><br>
<a href="{{ URL::to('blog/'.$blog_data->slug) }}"><i class="fas fa-chevron-left text-secondary"></i></a>
<a href="{{ URL::to('blog/'.$blog_data->slug) }}">{{substr(strip_tags($blog_data->title), 0, 80)}}</a>
<?php } ?>
</div>
<div id="box2">
<?php $last =App\BlogPost::latest()->first();
$id1 = $blog->id;
if( $id1 == $last->id) {
echo "";
}
else {
$id1++;
$blog_data1 = App\BlogPost::select('*')->where('id', $id1)->first();
?>
<a href="{{ URL::to('blog/'.$blog_data1->slug) }}" class="color_maroon">NEXT</a><br>
<a href="{{ URL::to('blog/'.$blog_data1->slug) }}">{{substr(strip_tags($blog_data1->title), 0, 80)}}</a>
<a href="{{ URL::to('blog/'.$blog_data1->slug) }}"><i class="fas fa-chevron-right text-secondary"></i></a>
<?php } ?>
</div>
</div>
<hr>
</div>
Comments
Post a Comment