vaersaagod / seomate

SEO, mate! It's important. That's why SEOMate provides the tools you need to craft all the meta tags, sitemaps and JSON-LD microdata you need - in one highly configurable, open and friendly package - with a super-light footprint.
MIT License
36 stars 8 forks source link

Rendering sitemap from matrix-field #59

Closed havardlj closed 2 years ago

havardlj commented 2 years ago

Is there any way of rendering the sitemap from the navigation matrix field I have in my globals, where I could add another field for the priority? I read that rendering functions is a feature that's exclusive to additionalMeta, but I was hoping to do a loop that would output something like (pardon this weird mix of php and twig): 'custom' => [ {% for link in globalNav.navMatrix %} '/{{ link.uri }}' => ['changefreq' => 'weekly', 'priority' => {{ link.priority}} ], {% endfor %} ]

mmikkel commented 2 years ago

That's not possible, but you can try something like this (not tested, but I think it should work):

'elements' => [
    'nav' => [
        'elementType' => \craft\elements\Entry::class,
        'criteria' => [
            'relatedTo' => [
                'sourceElement' => \craft\elements\GlobalSet::find()->handle('globalNav'),
                'field' => 'navMatrix'
            ],
        ],
        'params' => ['changefreq' => 'daily', 'priority' => 0.5],
    ],
],

Alternatively, you could create your own, custom sitemap using a Twig template, and add it using the additionalSiteMaps key.