aurelianspodarec's avatar

Dynamic Pagination

Hey there!

I wonder, how would you go about making the pagintion data dynamic, based on some parameters?

So I have a layout that has a filtering menu and pagination, the only thing that's different is the content in between.

So my question is, how do you make this dynamic:

 {{ $houses->links() }}
 {{ $flats->links() }}

The variable would need to be dynamic.

In my filtering menu I did something like this: {{Request::getPathInfo()}}?pageName={{$url }}"> which sees to work so far for all pages.

0 likes
6 replies
lat4732's avatar

What do you mean by "dynamic pagination"? AJAX based pagination or what?

aurelianspodarec's avatar

@Laralex

So this variable would be dynamic: houses and flats,normal blade file.

{{ $houses->links() }}
 {{ $flats->links() }}

The pages share the same layout basically.

Worst case scenario can go with a switch or if/else statement to check what page it is and write the URL manually.

aurelianspodarec's avatar

@Laralex I want one layout file that includes the filtering and pagination.

The data is different though.

layout

<x-layouts.main>
 
    <x-container>
        <x-inspiration.filter.index />
    </x-container>

    @yield('content')

    <div>
    {{ $Route::current()->links() }}
    </div>

</x-layouts.main>

Basically this, but this part is wrong $Route::current()->links()

Snapey's avatar
Snapey
Best Answer
Level 122

use the same variable name in both cases , eg $model->links

aurelianspodarec's avatar

@Snapey Hmmm fair enough.

I named the variable data. And kept the for each second parameter as it was for clarification.

I though there would be some more magical way of doing it, I guess not :D

Please or to participate in this conversation.