Skip to content

Commit

Permalink
Redirect to the last-selected source when saving assets, categories, …
Browse files Browse the repository at this point in the history
…and entries

Resolves #11996
  • Loading branch information
brandonkelly committed Oct 27, 2022
1 parent c3ea31d commit 379cdc5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release Notes for Craft CMS 4.4 (WIP)

### Content Management
- Assets, categories, and entries will now redirect to the last-selected source on their index pages when saved. ([#11996](https://github.com/craftcms/cms/discussions/11996))
8 changes: 1 addition & 7 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,13 +1031,7 @@ protected function cpEditUrl(): ?string
*/
public function getPostEditUrl(): ?string
{
$volume = $this->getVolume();
$uri = "assets/$volume->handle";
if ($this->folderPath !== null) {
$subfolders = ArrayHelper::filterEmptyStringsFromArray(explode('/', $this->folderPath));
$uri .= sprintf('/%s', implode('/', $subfolders));
}
return UrlHelper::cpUrl($uri);
return UrlHelper::cpUrl('assets');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,7 @@ protected function cpEditUrl(): ?string
*/
public function getPostEditUrl(): ?string
{
$group = $this->getGroup();
return UrlHelper::cpUrl("categories/$group->handle");
return UrlHelper::cpUrl('categories');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1432,9 +1432,7 @@ protected function cpEditUrl(): ?string
*/
public function getPostEditUrl(): ?string
{
$section = $this->getSection();
$sourceKey = $section->type === Section::TYPE_SINGLE ? 'singles' : $section->handle;
return UrlHelper::cpUrl("entries/$sourceKey");
return UrlHelper::cpUrl('entries');
}

/**
Expand Down

0 comments on commit 379cdc5

Please sign in to comment.