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

Properties returned by functions #14

Closed piotrpog closed 7 months ago

piotrpog commented 5 years ago

I tried to pass some string to title field instead of using values from fields. To do that i deduced i need to use function instead of field handle. Like it was showed in docs:

      'og:see_also' => function ($context) {
            $someLinks = [];
            $matrixBlocks = $context['globalSeo']->someLinks->all() ?? null;

            if ($matrixBlocks && count($matrixBlocks) > 0) {
                foreach ($matrixBlocks as $matrixBlock) {
                    $someLinks[] = $matrixBlock->someLinkUrl ?? '';
                }
            }

            return $someLinks;
        },

So i tried to test it, like this:

            'title' => function ($context) {
                return 'test';
        },

Unfortunetly it does not work, title takes value of site name if i try this.

bleepsandblops commented 5 years ago

Am having the exact same issue.

mmikkel commented 5 years ago

Rendering functions is actually a feature that's exclusive to additionalMeta (the docs could be clearer about that). However, I guess I can see how this feature could be useful to fieldProfiles or defaultMeta, so I'll label this as a feature request for now.

mmikkel commented 7 months ago

Support for closures (and Twig object templates) in fieldProfiles and defaultMeta has been added to SEOMate 3.0 (currently in beta) for Craft 5 🎉

See the updated docs on the fieldProfiles setting for more info.