Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previous / Next Article function won't work #31

Open
guime7000 opened this issue Feb 19, 2023 · 6 comments
Open

Previous / Next Article function won't work #31

guime7000 opened this issue Feb 19, 2023 · 6 comments
Assignees

Comments

@guime7000
Copy link

guime7000 commented Feb 19, 2023

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....

@ParitoshBh ParitoshBh self-assigned this Feb 20, 2023
@ParitoshBh
Copy link
Owner

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

@guime7000
Copy link
Author

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) ?

@ParitoshBh
Copy link
Owner

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?

@guime7000
Copy link
Author

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

@ParitoshBh
Copy link
Owner

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

@oldstonegryzzly
Copy link

oldstonegryzzly commented Jun 5, 2024

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants