Dashboard Menu Modification
August 7, 2025 ยท AI Conversations
User
Assistant
To **remove the main menu entry `/dashboard/shopping_feed` from the sidebar navigation** but **keep the alias under `/dashboard/store/feed` visible**, you should **exclude the original main page from the navigation**, **but not the alias**.
Here's the corrected section of your `addDashboardPages()` method:
### โ Updated `addDashboardPages()` Logic:
protected function addDashboardPages()
{
$pages = [
'/dashboard/shopping_feed' => ['Shopping Feed', 'Shopping Feed Tools'],
'/dashboard/shopping_feed/view' => ['Manage Feeds', 'List and manage feeds'],
'/dashboard/shopping_feed/tracklog' => ['Tracking Log', 'View tracking log'],
'/dashboard/shopping_feed/add' => ['Add Feed', 'Add a new feed'],
'/dashboard/shopping_feed/edit' => ['Edit Feed', 'Edit an existing feed'],
'/dashboard/shopping_feed/settings' => ['Settings', 'Settings'],
];
foreach ($pages as $path => [$name, $desc]) {
$page = Page::getByPath($path);
if ($page->isError()) {
$page = Single::add($path, $this);
}
if (is_object($page) && !$page->isError()) {
$page->update(['cName' => $name, 'cDescription' => $desc]);
// ๐ Exclude ALL pages including the main one from the navigation
$page->setAttribute('exclude_nav', true);
}
}
// โ
Create visible alias under Community Store
$pkgService = Core::make(PackageService::class);
$communityStore = $pkgService->getByHandle('community_store');
if ($communityStore && is_object($communityStore)) {
$mainPage = Page::getByPath('/dashboard/shopping_feed');
$parent = Page::getByPath('/dashboard/store');
$aliasExists = Page::getByPath('/dashboard/store/feed');
if ($mainPage && !$mainPage->isError() && $parent && !$parent->isError() && (!$aliasExists || $aliasExists->isError())) {
$alias = $mainPage->addCollectionAlias($parent);
if ($alias instanceof Page && !$alias->isError()) {
$alias->update(['cName' => 'Feed']);
$alias->setAttribute('exclude_nav', false); // ๐ Show only the alias in the nav
}
}
}
}
### โ
Summary of What This Does:
– Hides the original `/dashboard/shopping_feed` and its subpages.
– Keeps the alias `/dashboard/store/feed` **visible in the sidebar navigation**.
– Ensures clean navigation only under the **Store โ Feed** section.
Let me know if you want to hide the "Feed" alias later dynamically based on user permissions or other logic.