This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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
You can also pass a view to the render method:
public function render($view = null, $data = [])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
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 96Looks 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
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
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