Closed piotrpog closed 5 years ago
Hi @piotrpog – sorry about the late response.
The field profiles use the current element (i.e. the entry
or category
etc. matched to the current URL request) as their field value context, and do not look at Global Sets for field values at all – unlike defaultMeta
and additionalMeta
, which use the global Twig context and will drill down into Global Sets looking for values.
I don't think it'd make sense to have field profiles look at Global Sets for field values; this would introduce additional overhead and complexity to achieve something that I'd consider an edge case.
To display the seo.seoFields:settings.globalTitle
field value for the homepage entry's title
attribute, you can either
seo.seoFields:settings.globalTitle
field to the defaultMeta
's title
attribute, and it'll render for any field profile that doesn't have a valid title
attribute:'defaultMeta' => [
'description' => ['seo.seoFields:settings.globalDescription'],
'image' => ['seo.seoFields:settings.seoImage'],
'title' => ['seo.seoFields:settings.globalTitle'],
],
'fieldProfiles' => [
'home' => [], // Keep it empty to only render values from `defaultMeta`
],
'profileMap' => [
'home' => 'home',
],
title
attribute in Twig (this would go into the relevant Entry template, e.g. templates/homepage.twig
) to pull the Global Set's field (or whatever else):{% extends '_layouts/default' %}
{% set seomate = {
meta: {
title: seo.seoFields.type('settings').one().globalTitle
}
} %}
{% block content %}
...
@mmikkel Sorry for the late reply - just wanted to say thanks for explaining it to me.
Here is my config:
This fragment works correctly, description value is taken from global field:
This fragment does not work. Title shows site name instead: