Skip to content

Commit

Permalink
refactor: Always display the type menu and enforce editing the specif…
Browse files Browse the repository at this point in the history
…ic type
  • Loading branch information
khalwat committed Jan 15, 2025
1 parent b9d1b92 commit c3a7a4c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,18 +527,12 @@ public function actionEditContent(
}
$variables['typeMenu'] = $typeMenu;
$variables['currentTypeId'] = null;
$variables['specificTypeId'] = null;
if (count($typeMenu) > 1) {
if (!empty($typeMenu)) {
$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 {
Expand Down Expand Up @@ -648,7 +642,6 @@ 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');
Expand Down Expand Up @@ -687,12 +680,6 @@ 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.'));
Expand Down

0 comments on commit c3a7a4c

Please sign in to comment.