Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

"previous page" & "next page"

Solved by pamtbaau View solution

Started by Taylor Ren 6 years ago · 6 replies · 1800 views
6 years ago

I am now starting to migrate my previous wiki sites to Grav (trying hard).

Clipboard01|603x235

In one of the "topics", I may have over 20 "pages" (see above for a quick illustration, with 01/02...). I wish to place a link in each page (default.md in each folder) to link to "prev page" and "next page".

Appreciate your help on this.

6 years ago Solution

@taylorren, If you are still using an inherited theme based on Quark, the functionality is already available.

To implement 'Next' and 'Previous' on your pages, you need to do the following:

  • In page '09.gcti/default.md', define a collection of pages.
    YAML
    ---
    content:
     items: '@self.children'
    ---
    

    Every child-page can now use functions like page.nextSibling and page.isLast in templates. Template '/quark/templates/partials/blog-item.html.twig' is an example using it.

  • Change the template for all the subpages, eg. '01.toc/default.md', from 'default.md' to 'item.md'.
    This will turn each page into a blog item page.

    Your folder structure should now look as follows:

    TXT
    ./pages/
    ├── ...
    ├── 09.gcti
    │   ├── 01.toc
    │   │   └── item.md
    │   ├── 02.preface
    │   │   └── item.md
    │   ├── 03.other
    │   │   └── item.md
    │   └── default.md
    ├── ...
    
  • Done!

Bonus suggestion:
What you are trying to achieve very much looks likes a blog functionality. You might want to have a look at the 'Blog Site' skeleton which gives you an idea of how a blog using the Quark theme looks like.

NB. The above steps uses the build-in blog functionality of Quark. If you want 'gcti' to show a list of 'items', you should rename '09.gcti/default.md' into '09.gcti/blog.md'

👍 1
last edited 02/01/20 by pamtbaau
6 years ago

Thanks and I will try.

And thanks for the bonus tip. Actually I am not writing a blog in this sense. I have a dedicated WordPress site solely for blog purpose.

I use wiki-type of framework to have a better navigation between pages with tight connections. For example, all pages in gcti will belong to, in this case, a book.

6 years ago

Hi @taylorren, I do something similar in my Bootstrap4 Open Matter and Quark Open Publishing themes called "Sections" where based on a folder hierarchy next/prev page buttons are automatically generated. Support for a taxonomy tag called filter is also supported to dynamically generate different views of the pages.

You can see a live demo at:
https://demo.hibbittsdesign.org/grav-open-publishing-quark/multi-section-page

And here is it's page structure:
https://github.com/paulhibbitts/demo-grav-open-publishing-quark/tree/master/pages/05.multi-section-page

And view it's related Twig at:
https://github.com/hibbitts-design/grav-theme-quark-open-publishing/blob/master/templates/sections.html.twig

Hope the above might be helpful.
Paul

👍 1
6 years ago

I have done it and tweaked a bit. Now it is working very fine. Thanks!

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 76 8 hours ago
General · by pamtbaau, 13 hours ago
1 47 13 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago