picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 617 forks source link

How to make lazy load? #408

Closed mmmykhailo closed 6 years ago

mmmykhailo commented 6 years ago

Hi, how to make page with pages that will be complementing after page load?

PhrozenByte commented 6 years ago

Unfortunately you're providing basically zero information about what you're trying to do.

mmmykhailo commented 6 years ago

I have page base_url/pages. I have many other pages base_url/page/page.title. I need to load every page title to make a list. They should be loaded piece by piece because there are too many pages. What more information do you need?

PhrozenByte commented 6 years ago

You can use arbitrary conditions when iterating through your pages list to filter pages in Twig templates (see https://twig.symfony.com/doc/1.x/), e.g. use something like the following in your themes/my_theme/index.twig:

{% for page in pages %}
    {% if page.author == "John Doe" %}
        <h2>{{ page.title }}</h2>
    {% endif %}
{% endfor %}

I'm still not sure what you're trying to do, you'll have to ask way more specific questions. Please refer to Pico's docs (http://picocms.org/docs/) for basic details about how Pico works and how to customize Pico to fit your needs. Especially take a look at the Customization section. You can find 3rd-party themes (http://picocms.org/themes/) and plugins (http://picocms.org/plugins/) on our website, and even more themes (https://github.com/picocms/Pico/wiki/Pico-Themes) and plugins (https://github.com/picocms/Pico/wiki/Pico-Plugins) in our wiki.

mmmykhailo commented 6 years ago

I did it

{% for page in pages %}
    {% if page.author == "John Doe" %}
        <h2>{{ page.title }}</h2>
    {% endif %}
{% endfor %}

But when there are too many pages the page with the list of pages loads too long, so I want to load the list item by item after load of the page with this list...

mmmykhailo commented 6 years ago

In other words I need "SHOW MORE POSTS" button

PhrozenByte commented 6 years ago

Try the 3rd-party Pagination plugin.

mmmykhailo commented 6 years ago

Is there possible to make "show more" istead of "next"?

PhrozenByte commented 6 years ago

Please take a look at the plugin's README.md.

mmmykhailo commented 6 years ago

I read it. I understand that it possible to make "Show more" link to next page, but I need to insert new links in the same page without reload

PhrozenByte commented 6 years ago

Then you'll have to create the appropriate JavaScript code to load a pages list using AJAX. You can create a page returning JSON by creating e.g. a themes/my_theme/pages_ajax.twig and a small plugin to set the HTTP response's Content-Type of this page to application/json. Take a look at Pico's plugins/DummyPlugin.php, http://picocms.org/development/ and the code of existing Pico plugins out there. AFAIK there's no plugin or theme using something like this yet, so you'll have to develop it on your own. If you have any concrete question while developing this please don't hesitate to ask. However, I unfortunately can't provide you with the final solution, this is up to you (or some other developer).

mmmykhailo commented 6 years ago

Thank you for try to help..