getgrav / grav-plugin-sitemap

Grav Sitemap Plugin
https://getgrav.org
MIT License
42 stars 42 forks source link

Possible conflict with a particular config on Related Pages plugin #22

Closed paulmassen closed 8 years ago

paulmassen commented 8 years ago

Hi, It seems like sitemap can not be generated when related pages plugin is set with @self.siblings whereas it works with @self or @taxonomy. I got the message Call to a member function children() on null.

Here is my config: Related pages v1.1.3 Sitemap v1.6.2 Grav v1.1.0 - Admin v1.1.1 (Had the same problem with Grav v1.0.10)

Page.php

                            break;
                        case 'all':
                            $results = $this->children();
                            break;
                        case 'parent':
                            $collection = new Collection();
                            $results = $collection->addPage($this->parent());
                            break;
                        case 'siblings':
                            $results = $this->parent()->children()->remove($this->path());
                            break;
                        case 'descendants':
                            $results = $pages->all($this)->remove($this->path())->nonModular();
                            break;
                    }
                }

                $results = $results->published();
                break;

Here is the yaml just in case:

enabled: true
limit: 3
show_score: false
score_threshold: 20
filter:
  items: '@self.siblings'
  order:
    by: date
    dir: desc
page_in_filter: false
explicit_pages:
  process: true
  score: 100
taxonomy_match:
  taxonomy: tag
  taxonomy_taxonomy:
    process: true
    score_scale:
      1: '50'
      2: '75'
      3: '100'
  taxonomy_content:
    process: true
    score_scale:
      1: '20'
      2: '30'
      3: '45'
      4: '60'
      5: '70'
      6: '80'
      7: '90'
      8: '100'
content_match:
  process: true

And obviously the yaml for sitemap:

enabled: true
route: '/sitemap'
ignores:
  - /blog/blog-post-to-ignore
  - /ignore-this-route
flaviocopes commented 8 years ago

Replicated the issue.

The Related Pages plugin should really have a configuration option to be enabled only on some routes (e.g. on /blog and children) and not simply run on every page.

flaviocopes commented 8 years ago

Fixed by core Grav commit https://github.com/getgrav/grav/commit/07beafc679049108fed5f4261ce2cc1a67a72c8e