grav-coder icon indicating copy to clipboard operation
grav-coder copied to clipboard

Previous / Next Article function won't work

Open guime7000 opened this issue 2 years ago • 6 comments

Hi !

Thanks for the work on grav-coder, I really like the sobriety of your theme !

Don't know if this should be a PR or if it's an issue due to a misconfiguration or misunderstanding of how the theme is working....

I've been in trouble to make the previous / next Article function work. Related links were always corresponding to the current article URL. I'm using Grav v1.7.38.

I managed to get it work modifying the file navigation.html.twig in /grav-coder/templates/partials/item/

I replaced page.prevSibling().slug (resp. nextSibling)

with page.parent().children().prevSibling(page.path).url (resp. nextSibling)

and...tadam, it worked....

guime7000 avatar Feb 19 '23 20:02 guime7000

Pagination logic is already there in the theme itself. You shouldn't have needed to make the changes you made.

Can you please confirm if,

  1. you've followed the instructions as mentioned under Blog (Listing) Setup?
  2. you've updated grav-coder.yaml to include following config,
post:
  navigation: true

ParitoshBh avatar Feb 20 '23 18:02 ParitoshBh

Hi !

My directory and file structure is :

mygrav/
└── grav-admin/
    └── user/
        └── pages/
            ├── 01.blog/
            │   ├── 02.dir1/
            │   │   └── item.md
            │   ├── 03.dir2/
            │   │   └── item.md
            │   ├── 04.dir3/
            │   │   └── item.md
            │   └── blog.md
            └── 02.Typography

Inside 01.blog directory, my blog.md contains :

---
 content:
     items: '@self.children'
     order:
         by: date
         dir: desc
     limit: 10
     pagination: true
 metadata:
   description: 'Some description for metadata'
 ---

and my grav-coder.yaml file inside mygrav//grav-admin/user/themes/grav-coder/ contains :

enabled: true
dropdown:
  enabled: true
navbar:
  title: MyTitle
#  url: https:/myurl/blog
#  rel: me
  auth_link:
    enabled: false
    login_slug: login
    login_label: Login
#footer:
#  copyright: Grav Coder

social:
  github:
    title: Github
    url: https://mygithubURL
    icon: fab fa-github
    rel: me
  linkedin:
    title: LinkedIn
    url: https:/myLinkedInURL
    icon: fab fa-linkedin-in
    rel: me
post:
  navigation: true
  taxonomy: true
#listing_title:
#  taxonomy:
#    category: 'Category: '
#    tag: 'Tag: '
#  blogs: 'Posts'
pages:
  order:
    by: default
    dir: asc

pagination:
  count: 10

So where could be my mistake(s) ?

guime7000 avatar Feb 20 '23 22:02 guime7000

I tested your setup with grav version 1.7.35 and 1.7.38 and the navigation links work just fine. And your configs seem to be fine as well. The directory structure however, seems interesting. Since I cannot reproduce it on my end, would you be able to share a bare minimum zip of your setup?

ParitoshBh avatar Feb 22 '23 21:02 ParitoshBh

For sure ! Tell me what you need in the zip file, and I'll attach it !

guime7000 avatar Feb 22 '23 21:02 guime7000

Based on your file structure, I would say a zip of mygrav directory. Please redact any private information and if you aren't comfortable sharing zip here (or it is too big), feel free to send it to my email paritoshbh [at] outlook [dot] com

ParitoshBh avatar Feb 23 '23 17:02 ParitoshBh

I have the same problem, partially resolved with page.parent().children().prevSibling(page.path).url but {% if not page.isLast %} and {% if not page.isFirst %} dont work properly : next and prev they also remain on the first and last page.

edit:

next and prev work fine with: {% if not page.parent().children().isFirst(page.path) %}

Grav 1.7.46 - Admin v1.10.46

thanks for your works and sorry for my bad english...

oldstonegryzzly avatar Jun 05 '24 15:06 oldstonegryzzly