Field profile map specificity and support for Commerce products and users #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to create more specific field profile mappings.
Previously, field profiles were mapped by simple handles only, where the key(s) would be matched to the elements' section or category group handles:
The above config would result in the
newsProfile
field profile being used for elements belonging to either a section with the handlenews
or a category group with that same handle.This PR retains this behaviour (and expands it to also include Craft Commerce products), but adds the ability to create more specific profile mappings by prefixing keys with either
section:
,entryType:
,categoryGroup:
,productType:
oruser:
. As an example:Profile mappings are matched from highest to lowest specificity, i.e. for entries SEOMate will first look for a matching profile using the "entryType:" or "section:" syntax, before looking at the "unspecific" profiles (i.e. the ones not using the "sourceType:handle" syntax. Similarly for categories, SEOMate will first look for a matching profile using the "categoryGroup:" syntax, before looking at the unspecific profiles.
This PR should be mostly backwards compatible, but might require some adjustments to existing SEOMate config files in rare cases.
This PR also fixes #85, by making the
SEOMateHelper::getElementProfile()
method more defensive when querying for entry sections.