diff --git a/src/controllers/SettingsController.php b/src/controllers/SettingsController.php index daf3ebb42..44fcc1d2f 100644 --- a/src/controllers/SettingsController.php +++ b/src/controllers/SettingsController.php @@ -537,12 +537,18 @@ public function actionEditContent( } $variables['typeMenu'] = $typeMenu; $variables['currentTypeId'] = null; - if (!empty($typeMenu)) { + $variables['specificTypeId'] = null; + if (count($typeMenu) > 1) { $currentType = reset($typeMenu); $variables['currentType'] = $typeMenu[$typeId] ?? $currentType; $variables['currentTypeId'] = $typeId ?? key($typeMenu); $typeId = (int)$variables['currentTypeId']; } + // If there's only one EntryType, don't bother displaying the menu + if (count($typeMenu) === 1) { + $variables['typeMenu'] = []; + $variables['specificTypeId'] = $typeId ?? key($typeMenu); + } $pluginName = Seomatic::$settings->pluginName; // Asset bundle try { @@ -653,6 +659,7 @@ public function actionSaveContent(): Response $sourceHandle = $request->getParam('sourceHandle'); $siteId = $request->getParam('siteId'); $typeId = $request->getParam('typeId') ?? null; + $specificTypeId = $request->getParam('specificTypeId') ?? null; $globalsSettings = $request->getParam('metaGlobalVars'); $bundleSettings = $request->getParam('metaBundleSettings'); $sitemapSettings = $request->getParam('metaSitemapVars'); @@ -691,6 +698,12 @@ public function actionSaveContent(): Response Seomatic::$plugin->metaBundles->syncBundleWithConfig($metaBundle, true); $metaBundle->typeId = $typeId; Seomatic::$plugin->metaBundles->updateMetaBundle($metaBundle, $siteId); + // If there's also a specific typeId associated with this section, save the same + // metabundle there too, to fix: https://github.com/nystudio107/craft-seomatic/issues/1557 + if (!empty($specificTypeId)) { + $metaBundle->typeId = $specificTypeId; + Seomatic::$plugin->metaBundles->updateMetaBundle($metaBundle, $siteId); + } Seomatic::$plugin->clearAllCaches(); Craft::$app->getSession()->setNotice(Craft::t('seomatic', 'SEOmatic content settings saved.')); diff --git a/src/seoelements/SeoEntry.php b/src/seoelements/SeoEntry.php index ad2bf0064..2a5e8e31e 100644 --- a/src/seoelements/SeoEntry.php +++ b/src/seoelements/SeoEntry.php @@ -321,11 +321,8 @@ public static function typeMenuFromHandle(string $sourceHandle): array $section = self::sourceModelFromHandle($sourceHandle); if ($section !== null) { $entryTypes = $section->getEntryTypes(); - // Only create a menu if there's more than 1 entry type - if (count($entryTypes) > 1) { - foreach ($entryTypes as $entryType) { - $typeMenu[$entryType->id] = $entryType->name; - } + foreach ($entryTypes as $entryType) { + $typeMenu[$entryType->id] = $entryType->name; } }