Closed tomsonar closed 10 years ago
You can set this up as a view composer:
View::composer('default.post', function($view) {
$prev = DB::table('posts')->orderBy('id', 'asc')->where('id', '>', $view->post->id)->where('active', '1')->first();
$next = DB::table('posts')->orderBy('id', 'desc')->where('id', '<', $view->post->id)->where('active', '1')->first();
$view->with(compact('prev', 'next'));
});
Change the 'default.post' to whatever theme you are using.
Thanks. I added a view composer class, service provider, and added it to the bootstrap process and composer.json. Phew that was a workout =) Hopefully this is still a good thing to add to the core package one day. Seems popular.
Is this something we can add somewhere to alter Wardrobe without having to make edits to the package code? Or does it need to be implemented in the core?
Basically, here's what is desired: http://blog.marcomonteiro.net/post/how-to-add-previous-and-next-links-on-wardrobe
Thanks