This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

rafaelteboekhort56195
rafaelteboekhort56195

Hello there! Im new at octobercms and I love it! Lots to learn though. So, I managed to connect a database through a model to my website. Now I want to paginate the results. All works fine. I just want to change the generated html by .render in {{ users.render|raw }} Can anyone tell me how to do this? Im looking through the documentation but probably I am not finding anything.. Best, Rafael

Last updated

mjauvin
mjauvin
mjauvin

You can also pass a view to the render method:

public function render($view = null, $data = [])
rafaelteboekhort56195
rafaelteboekhort56195

Thanks a lot mjauvin!! Putting your tips to work right now ))

rafaelteboekhort56195
rafaelteboekhort56195

Everything works wonderfully! But I have one last small thing going on )). I have a lot of pages, say 60 or something (I did ->paginate(10)) and now I need to make the paginator have ... between the pages, like so:

<1, 2, 3 ... 6, 7, 8>

Im seraching around for something like {{ $users->onEachSide(5)->links() }} in Laravel right now

Any tips on how to build something like that?

Last updated

mjauvin
mjauvin

Doesn't onEachSide() work?

rafaelteboekhorst56221
rafaelteboekhorst56221

I think I am doing something wrong. When I add something like this in my component:

    public function loadHouses()
    {
        $hello = Houses::paginate(10)->onEachSide(5);
        return $hello;
    }

I get an error message saying:

Method onEachSide does not exist.

/var/www/html/october/myoctober/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php line 96
mjauvin
mjauvin

Looks like that got added in Laravel 5.8... October will soon be released with Laravel 6 as a foundation, so that'll work.

https://laravel.com/api/5.8/Illuminate/Pagination/LengthAwarePaginator.html

October currently uses Laravel 5.5

Last updated

Dione
Dione

mjauvin said:

See this trick:

https://octobertricks.com/tricks/customize-pagination-markup

Thank you so much mjauvin, your link helped me

I want to know how can i style active pagination button, somethink like {% if this.page.id == 'page' %} active {% endif %} I hope you can help me with that

mjauvin
mjauvin

What about this?

{% if results.hasPages %}
    <ul class="pagination">
        <li>
            {% if results.currentPage > 1 %}
                <a href="{{ results.previousPageUrl }}" rel="prev">«</a>
            {% else %}
                <span class="disabled">«</span>
            {% endif %}
        </li>

        {% for page in range(1, results.lastPage) %}
            <li {{ results.currentPage == page ? 'class="active"' }}>
                <a href="{{ results.url(page) }}">{{ page }}</a>
            </li>
        {% endfor %}

        <li>
            {% if results.hasMorePages %}
                <a href="{{ results.nextPageUrl }}" rel="next">»</a>
            {% else %}
                <span class="disabled">»</span>
            {% endif %}
        </li>
    </ul>
{% endif %}

1-10 of 10

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.