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

Trying to use related pages plugin

Started by Muut Archive 10 years ago · 5 replies · 543 views
10 years ago

Hi,

I am trying to use the related pages plugin.
In the configuration file you have to add a specific item (tag) to compare the pages. I don't fully understand why you have to fill in the Items attribute in the config? Should it not be able to rate the pages based on the taxonomy of the current page? To make it work, i have to fill in specific tags, otherwise it wont return pages. It only matches these specific tags?

With the current yaml settings, it will return pages..

YAML
filter:
  items:
    '@taxonomy.tag':
      - test4
      - test2
      - test

Best regards!

10 years ago

Correct, basically the filter tells the plugin which files to gather up and compare in order to find related pages. My goto example is usually:

YAML
filter:
    items:
        '@page': /blog 

This way it will use the page collection defined in the /blog page which makes sense when I'm using this plugin to find other related blog pages. However if you wanted to use a variety of pages, you could simply assign each one a specific category and use that:

YAML
taxonomy:
   category: relatable

Then in the plugin configuration:

YAML

filter:
    items:
        '@taxonomy.category': relatable
---
10 years ago

@rhukster, I had a problem on a project recently: Let's say I had two distinct blog pages: /blog1 and /blog2 , how would you define the plugin yaml in order to make sure that blog1 pages does not display related pages that are from blog2?

10 years ago

Thx @rhukster for clearing things up. i think will use the category way.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1369 9 years ago
Archive · by Muut Archive, 9 years ago
2 943 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1126 9 years ago