Shopping Feed Dashboard Alias
August 7, 2025 · AI Conversations
Your current code already does this correctly — **it creates an alias but does not remove or hide the original page**. But for clarity and proper ordering, here's a slightly cleaned-up and confirmed working version of the relevant section.
### ✅ Updated Code Snippet for Aliasing Under `/dashboard/store`:
Replace only the `addDashboardPages()` method with the following updated version:
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/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 add/edit from nav only
if (in_array($path, [
'/dashboard/shopping_feed/add',
'/dashboard/shopping_feed/edit'
])) {
$page->setAttribute('exclude_nav', true);
}
}
}
// ✅ Create alias under /dashboard/store if Community Store is installed
$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');
$isMainPageValid = ($mainPage instanceof Page && !$mainPage->isError());
$isParentValid = ($parent instanceof Page && !$parent->isError());
$aliasAlreadyExists = ($aliasExists instanceof Page && !$aliasExists->isError());
if ($isMainPageValid && $isParentValid && !$aliasAlreadyExists) {
$alias = $mainPage->addCollectionAlias($parent);
if ($alias instanceof Page && !$alias->isError()) {
$alias->update(['cName' => 'Feed']);
// Optionally set description if desired
// $alias->update(['cDescription' => 'Shopping Feed Tools']);
}
}
}
}
### ✅ This does the following:
– Keeps `/dashboard/shopping_feed` as a primary nav item.
– Adds an alias under `/dashboard/store/feed`.
– Excludes only the Add/Edit subpages from the nav.
– Does not remove or hide the original menu.
– Prevents duplicate alias creation.
Let me know if you also want to **completely remove** the original `/dashboard/shopping_feed` menu **but keep the alias**, or want to change the **icon or position** in the menu.
Your goal is:
✅ **Keep the original menu at** `/dashboard/shopping_feed`
✅ **Also show an alias under** `/dashboard/store/feed`
❌ But currently, it's not appearing under Community Store (`/dashboard/store`)
Let’s walk through and make sure it works.
—
### ✅ Final Working Fix
We'll do three things:
1. Create `/dashboard/shopping_feed` pages.
2. Ensure the alias is created under `/dashboard/store`.
3. Avoid duplicate alias creation.
Replace your entire `addDashboardPages()` function with this:
protected function addDashboardPages()
{
// Step 1: Create original pages under /dashboard/shopping_feed
$pages = [
'/dashboard/shopping_feed' => ['Shopping Feed', 'Shopping Feed Tools'],
'/dashboard/shopping_feed/view' => ['Manage Feeds', 'List and manage feeds'],
'/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', 'Feed Settings'],
];
foreach ($pages as $path => [$name, $desc]) {
$page = Page::getByPath($path);
if ($page->isError()) {
$page = Single::add($path, $this);
}
if ($page instanceof Page && !$page->isError()) {
$page->update(['cName' => $name, 'cDescription' => $desc]);
if (in_array($path, [
'/dashboard/shopping_feed/add',
'/dashboard/shopping_feed/edit'
])) {
$page->setAttribute('exclude_nav', true);
}
}
}
// Step 2: Add alias under /dashboard/store
$pkgService = Core::make(PackageService::class);
$communityStore = $pkgService->getByHandle('community_store');
if ($communityStore && is_object($communityStore)) {
$originalPage = Page::getByPath('/dashboard/shopping_feed');
$storeDashboard = Page::getByPath('/dashboard/store');
if ($originalPage && !$originalPage->isError() && $storeDashboard && !$storeDashboard->isError()) {
$existingAlias = Page::getByPath('/dashboard/store/feed');
if ($existingAlias->isError()) {
$alias = $originalPage->addCollectionAlias($storeDashboard);
if ($alias instanceof Page && !$alias->isError()) {
$alias->update(['cName' => 'Feed']);
}
}
}
}
}
—
### 🔁 Test Again
After adjusting:
1. **Uninstall and reinstall your package** OR temporarily bump the `$pkgVersion` to force `upgrade()`:
protected $pkgVersion = '1.0.1'; // bump this to force `upgrade()`
2. Run `php concrete/bin/concrete5 c5:package-update shopping_feed_manager`
Or uninstall → reinstall the package via Dashboard.
3. Then go to:
– `/dashboard/shopping_feed/view` → ✅ original page
– `/dashboard/store/feed` → ✅ new alias under Community Store
—
### ✅ Result
You will now have:
– `Shopping Feed` in the sidebar under **System & Settings**.
– A second menu called `Feed` under **Store** (Community Store).
Let me know if you'd like the same submenu (like View/Add/Settings) shown under `/dashboard/store/feed` too — that’s possible with extra aliasing.
Dashboard
└── Store
└── Shopping Feed ✅ (instead of being in its own top-level menu)
├── View
├── Add
├── Edit
└── Settings
—
### ✅ Final Solution: Move all pages under `/dashboard/store/shopping_feed`
To do this cleanly:
1. **Change the paths for all single pages**.
2. **Update routes and links accordingly**.
3. **Delete old `/dashboard/shopping_feed` paths if they exist**.
—
### ✅ Step-by-step Code Change
Replace your `addDashboardPages()` method with this:
protected function addDashboardPages()
{
$pages = [
'/dashboard/store/shopping_feed' => ['Shopping Feed', 'Shopping Feed Tools'],
'/dashboard/store/shopping_feed/view' => ['Manage Feeds', 'List and manage feeds'],
'/dashboard/store/shopping_feed/add' => ['Add Feed', 'Add a new feed'],
'/dashboard/store/shopping_feed/edit' => ['Edit Feed', 'Edit an existing feed'],
'/dashboard/store/shopping_feed/settings' => ['Settings', 'Feed Settings'],
];
foreach ($pages as $path => [$name, $desc]) {
$page = Page::getByPath($path);
if ($page->isError()) {
$page = Single::add($path, $this);
}
if ($page instanceof Page && !$page->isError()) {
$page->update(['cName' => $name, 'cDescription' => $desc]);
if (in_array($path, [
'/dashboard/store/shopping_feed/add',
'/dashboard/store/shopping_feed/edit'
])) {
$page->setAttribute('exclude_nav', true);
}
}
}
// ❌ Optionally remove old dashboard/shopping_feed if it exists
$old = Page::getByPath('/dashboard/shopping_feed');
if ($old && !$old->isError()) {
$old->delete();
}
}
—
### ✅ Update Your Routes
In your `on_start()` method, update this route:
Route::register('/dashboard/shopping_feed/deletefeed/{id}', 'Concrete\Package\ShoppingFeedManager\Controller\SinglePage\Dashboard\ShoppingFeed::deleteFeed');
To this:
Route::register('/dashboard/store/shopping_feed/deletefeed/{id}', 'Concrete\Package\ShoppingFeedManager\Controller\SinglePage\Dashboard\ShoppingFeed::deleteFeed');
Do the same for any other internal links in views/controllers.
—
### 🔁 Reinstall / Upgrade Package
To apply changes:
– **Option 1**: Uninstall and reinstall the package.
– **Option 2**: Bump version and run upgrade:
protected $pkgVersion = '1.0.1';
Then run:
php concrete/bin/concrete5 c5:package-update shopping_feed_manager
—
### ✅ Result
You’ll now have this menu path:
Dashboard
└── Store
└── Shopping Feed
├── View
├── Add
├── Edit
└── Settings
Let me know if you want submenus like Add/Edit to also appear in the left nav — or just hidden for routing!
—
### ✅ Solution: Add the pages manually under `/dashboard/store/shopping_feed` using the proper parent reference
To **add single pages under `/dashboard/store/shopping_feed`**, you must:
1. Get the `/dashboard/store` page as the parent.
2. Add subpages (single pages) under that parent with relative paths.
—
### 🔧 Replace your `addDashboardPages()` function with:
protected function addDashboardPages()
{
$pkg = $this;
// Get /dashboard/store as the parent
$storeDashboard = Page::getByPath('/dashboard/store');
if (!$storeDashboard || $storeDashboard->isError()) {
return; // store not installed
}
// Add main shopping feed page under /dashboard/store
$shoppingFeedPath = '/dashboard/store/shopping_feed';
$shoppingFeedPage = Page::getByPath($shoppingFeedPath);
if ($shoppingFeedPage->isError()) {
$shoppingFeedPage = Single::add($shoppingFeedPath, $pkg);
}
if ($shoppingFeedPage instanceof Page && !$shoppingFeedPage->isError()) {
$shoppingFeedPage->update([
'cName' => 'Shopping Feed',
'cDescription' => 'Shopping Feed Tools',
]);
}
// Define subpages under shopping_feed
$subPages = [
'/dashboard/store/shopping_feed/view' => ['Manage Feeds', 'List and manage feeds'],
'/dashboard/store/shopping_feed/add' => ['Add Feed', 'Add a new feed'],
'/dashboard/store/shopping_feed/edit' => ['Edit Feed', 'Edit an existing feed'],
'/dashboard/store/shopping_feed/settings' => ['Settings', 'Feed Settings'],
];
foreach ($subPages as $path => [$name, $desc]) {
$page = Page::getByPath($path);
if ($page->isError()) {
$page = Single::add($path, $pkg);
}
if ($page instanceof Page && !$page->isError()) {
$page->update(['cName' => $name, 'cDescription' => $desc]);
// Hide add/edit pages from the nav
if (str_contains($path, 'add') || str_contains($path, 'edit')) {
$page->setAttribute('exclude_nav', true);
}
}
}
// ✅ Optional: Remove old /dashboard/shopping_feed if it exists
$oldPage = Page::getByPath('/dashboard/shopping_feed');
if ($oldPage && !$oldPage->isError()) {
$oldPage->delete();
}
}
—
### ✅ Update Route in `on_start()`
Update this line:
Route::register('/dashboard/shopping_feed/deletefeed/{id}', ...)
To:
Route::register('/dashboard/store/shopping_feed/deletefeed/{id}', ...)
—
### ✅ Force Upgrade
To apply changes, bump version:
protected $pkgVersion = '1.0.1';
Then run:
php concrete/bin/concrete5 c5:package-update shopping_feed_manager
—
### 🎯 Final Result
You'll now have:
Dashboard
└── Store
└── Shopping Feed
├── View
├── Add
├── Edit
└── Settings
Let me know if you want it shown collapsed by default or want the top-level `/dashboard/shopping_feed` to stay active as well.
### ✅ Final Changes Implemented
1. Moves all dashboard pages to **`/dashboard/store/shopping_feed/…`**.
2. Ensures **menu is visible under the Community Store section**.
3. Cleans up and registers routes correctly for new paths.
4. Deletes old `/dashboard/shopping_feed` structure.
5. Handles asset loading for new `/dashboard/store/shopping_feed/…` paths.
—
### ✅ Full `controller.php` (final version)
<?php
// File: packages/shopping_feed_manager/controller.php
namespace ConcretePackageShoppingFeedManager;
use ConcreteCorePackagePackage;
use ConcreteCorePagePage;
use ConcreteCorePageSingle;
use ConcreteCoreDatabaseConnectionConnection;
use ConcreteCoreHttpRequest;
use ConcreteCoreAssetAssetList;
use ConcreteCorePackagePackageService;
use Route;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends Package
{
protected $pkgHandle = 'shopping_feed_manager';
protected $appVersionRequired = '9.0.0';
protected $pkgVersion = '1.0.1'; // bump to trigger upgrade
public function getPackageDescription()
{
return t("Google Merchant Shopping Feed package for ConcreteCMS");
}
public function getPackageName()
{
return t("Shopping Feed Manager");
}
public function install()
{
$pkg = parent::install();
$this->addDashboardPages();
$this->createTables();
}
public function upgrade()
{
parent::upgrade();
$this->addDashboardPages();
}
public function on_start()
{
// Register API routes
Route::register('/shopping_feed/api/feeds', 'Concrete\Package\ShoppingFeedManager\Controller\Api\FeedApi::view');
Route::register('/shopping_feed/api/delete/{id}', 'Concrete\Package\ShoppingFeedManager\Controller\Api\FeedApi::delete');
Route::register('/shopping_feed/api/clone/{id}', 'Concrete\Package\ShoppingFeedManager\Controller\Api\FeedApi::cloneFeed');
// Adjusted route for dashboard feed deletion
Route::register('/dashboard/store/shopping_feed/deletefeed/{id}', 'Concrete\Package\ShoppingFeedManager\Controller\SinglePage\Dashboard\ShoppingFeed::deleteFeed');
// Public XML feed generation
Route::register('/google-merchant-feed/{feedSlug}', 'Concrete\Package\ShoppingFeedManager\Controller\MerchantFeed::generateXml');
// Register JS/CSS assets
$al = AssetList::getInstance();
$al->register('javascript', 'react', 'https://unpkg.com/react@18/umd/react.development.js', ['local' => false]);
$al->register('javascript', 'react-dom', 'https://unpkg.com/react-dom@18/umd/react-dom.development.js', ['local' => false]);
$al->register('javascript', 'react-babel', 'https://unpkg.com/@babel/standalone/babel.min.js', ['local' => false]);
$al->register('javascript', 'feed-admin-js', 'js/admin-feed.js', [], $this);
$al->register('css', 'feed-admin-css', 'css/admin-feed.css', [], $this);
// Only load on feed dashboard pages
$req = $this->app->make(Request::class);
$path = $req->getPath();
if (str_starts_with($path, '/dashboard/store/shopping_feed')) {
$view = View::getInstance();
$view->requireAsset('javascript', 'react');
$view->requireAsset('javascript', 'react-dom');
$view->requireAsset('javascript', 'react-babel');
$view->requireAsset('javascript', 'feed-admin-js');
$view->requireAsset('css', 'feed-admin-css');
}
}
protected function createTables()
{
$db = $this->app->make(Connection::class);
$db->executeQuery("CREATE TABLE IF NOT EXISTS shoppingfeedconfiguration (
id INT AUTO_INCREMENT PRIMARY KEY,
url VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(355) NOT NULL,
feedSlug VARCHAR(355) NOT NULL,
settings TEXT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
latestGeneration TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
noOfProducts INT DEFAULT 0,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_name (name)
)");
$db->executeQuery("CREATE TABLE IF NOT EXISTS shoppingfeedlog (
id INT AUTO_INCREMENT PRIMARY KEY,
feed_id INT NOT NULL,
updated_at DATETIME NOT NULL,
status VARCHAR(50),
error_message TEXT,
INDEX idx_feed (feed_id),
INDEX idx_status (status),
INDEX idx_updated_at (updated_at),
FOREIGN KEY (feed_id) REFERENCES shoppingfeedconfiguration(id) ON DELETE CASCADE
)");
}
protected function addDashboardPages()
{
$pkg = $this;
// Ensure Community Store exists
$storeDashboard = Page::getByPath('/dashboard/store');
if (!$storeDashboard || $storeDashboard->isError()) {
return; // Community Store not installed
}
// Main Shopping Feed page under /dashboard/store
$mainPath = '/dashboard/store/shopping_feed';
$mainPage = Page::getByPath($mainPath);
if ($mainPage->isError()) {
$mainPage = Single::add($mainPath, $pkg);
}
if ($mainPage instanceof Page && !$mainPage->isError()) {
$mainPage->update(['cName' => 'Shopping Feed', 'cDescription' => 'Shopping Feed Tools']);
}
// Subpages
$subPages = [
'/dashboard/store/shopping_feed/view' => ['Manage Feeds', 'List and manage feeds'],
'/dashboard/store/shopping_feed/add' => ['Add Feed', 'Add a new feed'],
'/dashboard/store/shopping_feed/edit' => ['Edit Feed', 'Edit an existing feed'],
'/dashboard/store/shopping_feed/settings' => ['Settings', 'Feed Settings'],
];
foreach ($subPages as $path => [$name, $desc]) {
$page = Page::getByPath($path);
if ($page->isError()) {
$page = Single::add($path, $pkg);
}
if ($page instanceof Page && !$page->isError()) {
$page->update(['cName' => $name, 'cDescription' => $desc]);
if (str_contains($path, 'add') || str_contains($path, 'edit')) {
$page->setAttribute('exclude_nav', true);
}
}
}
// Remove old root-level shopping_feed if exists
$oldPage = Page::getByPath('/dashboard/shopping_feed');
if ($oldPage && !$oldPage->isError()) {
$oldPage->delete();
}
}
}
—
### ✅ Next Steps to Apply Changes
1. Make sure your `controller.php` matches this one.
2. Bump version (already done: `1.0.1`).
3. Run this command:
php concrete/bin/concrete5 c5:package-update shopping_feed_manager
4. Then check your Concrete CMS Dashboard under:
Dashboard → Store → Shopping Feed
Let me know if you also want to:
– Add icons next to the menu
– Collapse/expand submenu behavior
– Make the feed view the default page when clicking "Shopping Feed"
I'm happy to help further!
—
## ✅ 1. The View File Must Match the New Path
Concrete CMS **requires a matching view file for each single page path**, like:
### Your new page is:
/dashboard/store/shopping_feed
### So it **must have a view file at**:
packages/shopping_feed_manager/single_pages/dashboard/store/shopping_feed/view.php
> 🔥 If this file is missing, the page will 404.
—
### ✅ Folder Structure You Must Create:
packages/
└── shopping_feed_manager/
└── single_pages/
└── dashboard/
└── store/
└── shopping_feed/
├── view.php ← Required for /view
├── add.php ← For /add
├── edit.php ← For /edit
└── settings.php ← For /settings
Even if the files are empty placeholders for now, they **must exist** for the route to load.
Example `view.php`:
<?php
defined('C5_EXECUTE') or die('Access Denied.');
echo '<h1>Shopping Feed Dashboard</h1>';
—
## ✅ 2. Clear the Concrete CMS Cache
After adding those files:
Run this from terminal in your Concrete CMS root:
php concrete/bin/concrete5 c5:clear-cache
Or go to **Dashboard > System & Settings > Optimization > Clear Cache**.
—
## ✅ Summary of What to Check
| ✅ Requirement | Status |
|—————————————-|————|
| `/dashboard/store/shopping_feed` view exists | `single_pages/dashboard/store/shopping_feed/view.php` must exist |
| Add/Edit/Settings pages created | Add `add.php`, `edit.php`, `settings.php` |
| Package version bumped | Use `1.0.1` or higher |
| Upgrade command run | `php concrete/bin/concrete5 c5:package-update shopping_feed_manager` |
| Cache cleared | Yes |
—
## 🚀 Once Done
Navigate to:
/dashboard/store/shopping_feed/view
It should now show your dashboard!
Let me know if you'd like me to generate boilerplate content for all the `.php` files so you can test right away.
page remove right side shopping_feed menu
but don't remove which has /dashboard/store/ this part in url
menu strutcure is
Shopping Feed
—
### 🎯 **Remove this menu item:**
<li><a href="/index.php/dashboard/shopping_feed">Shopping Feed</a></li>
### ✅ But **keep this menu:**
<li><a href="/index.php/dashboard/store/shopping_feed">Shopping Feed</a></li>
—
### ✅ Why This Is Happening
Concrete CMS automatically adds a menu item for every page under `/dashboard/*`, including `/dashboard/shopping_feed`, **even if you moved your structure to `/dashboard/store/shopping_feed`**.
So to **remove only `/dashboard/shopping_feed`** menu:
—
## ✅ Solution: Explicitly delete `/dashboard/shopping_feed` page
You're likely still seeing the menu because **the old page exists in the database**, even if it's not being used anymore.
### ✔ Add this in your `addDashboardPages()` method:
Put it at the **very end** of the method:
// Remove old /dashboard/shopping_feed if it exists
$oldRootFeed = Page::getByPath('/dashboard/shopping_feed');
if ($oldRootFeed && !$oldRootFeed->isError()) {
$oldRootFeed->delete();
}
### 🔄 Make sure to also bump version:
protected $pkgVersion = '1.0.2';
### 🔁 Then run:
php concrete/bin/concrete5 c5:package-update shopping_feed_manager
—
## ✅ Clear
—
### ✅ Solution Using jQuery (Dashboard Admin UI)
Add this jQuery snippet to your admin page (e.g. inside `view.php` or in your admin JS file):
<script>
$(function () {
// Remove only the menu link that goes to /dashboard/shopping_feed (not /store/shopping_feed)
$('a[href*="/dashboard/shopping_feed"]').each(function () {
// Exclude ones under /dashboard/store/shopping_feed
if (!$(this).attr('href').includes('/dashboard/store/shopping_feed')) {
$(this).closest('li').remove();
}
});
});
</script>
—
### ✅ Where to Place It
You can place this in:
#### Option 1: Your `single_pages/dashboard/store/shopping_feed/view.php`
<?php defined('C5_EXECUTE') or die('Access Denied.'); ?>
<h2>Shopping Feed Manager</h2>
<script>
$(function () {
$('a[href*="/dashboard/shopping_feed"]').each(function () {
if (!$(this).attr('href').includes('/dashboard/store/shopping_feed')) {
$(this).closest('li').remove();
}
});
});
</script>
#### Option 2: Your custom admin JS (`js/admin-feed.js`)
Just add the same code inside `$(function () {})`.
—
### ✅ Result
– **Hides**: menu items linking to `/dashboard/shopping_feed`
– **Keeps**: anything under `/dashboard/store/shopping_feed`
– Works dynamically on page load
Let me know if you'd like to target only top-level dashboard sidebar menus or apply this on every dashboard page.
/index.php/dashboard/store/overview
other removes from all other pages
—
### 🎯 **Keep only this sidebar menu item:**
/index.php/dashboard/store/overview
### ❌ **Remove ALL other “ dashboard menu items**, no matter where they point.
—
### ✅ jQuery Solution
Place this script in your dashboard view (`view.php`) or your admin JS file (`admin-feed.js`):
<script>
$(function () {
$('nav li').each(function () {
const $link = $(this).find('a').first();
const href = $link.attr('href');
// Keep only "/dashboard/store/overview"
if (!href || !href.includes('/dashboard/store/overview')) {
$(this).remove();
}
});
});
</script>
—
### 🔍 What This Does:
– Loops through all “ in the sidebar.
– Gets each “ link’s `href`.
– Removes the “ unless the `href` contains `/dashboard/store/overview`.
—
### ✅ Where to Place
Put it inside your main dashboard view page:
<?php defined('C5_EXECUTE') or die('Access Denied.'); ?>
<h2>Shopping Feed</h2>
<script>
$(function () {
$('nav li').each(function () {
const $link = $(this).find('a').first();
const href = $link.attr('href');
if (!href || !href.includes('/dashboard/store/overview')) {
$(this).remove();
}
});
});
</script>
—
Let me know if you want to hide them **only on certain routes** (e.g., not on all dashboard pages).
this menu
—
### 🎯 **Remove this exact menu item:**
<li><a href="https://concrete-cms.ddev.site/index.php/dashboard/shopping_feed">Shopping Feed</a></li>
### ✅ jQuery to remove it by exact match:
Here is the precise jQuery you can use:
<script>
$(function () {
$('a[href="/index.php/dashboard/shopping_feed"]').closest('li').remove();
});
</script>
—
### ✅ Where to put it:
You can include this snippet in:
#### Option 1: Your dashboard view (`view.php`)
<?php defined('C5_EXECUTE') or die('Access Denied.'); ?>
<h2>Shopping Feed</h2>
<script>
$(function () {
$('a[href="/index.php/dashboard/shopping_feed"]').closest('li').remove();
});
</script>
#### Option 2: Inside `js/admin-feed.js`
If you're already including `feed-admin-js`, just add this jQuery code at the bottom of that file.
—
### ✅ Optional: Also handle HTTPS or trailing slash
If needed, use a *contains* style match instead of exact:
$('a[href*="/dashboard/shopping_feed"]').each(function () {
if (!$(this).attr('href').includes('/dashboard/store/shopping_feed')) {
$(this).closest('li').remove();
}
});
Let me know if you'd like to hide this menu only on certain pages or globally across the whole dashboard.
https://concrete-cms.ddev.site/index.php/dashboard/store/overview
—
### 🎯 **Hide this menu item:**
<li><a href="/index.php/dashboard/shopping_feed">Shopping Feed</a></li>
### ✅ But **only on pages EXCEPT** this one:
/index.php/dashboard/store/overview
—
### ✅ Final jQuery Solution
Place this script in your view or shared admin JS:
<script>
$(function () {
// Check current page path
const currentPath = window.location.pathname;
// If we are NOT on /dashboard/store/overview, remove the Shopping Feed menu item
if (!currentPath.includes('/dashboard/store/overview')) {
$('a[href="/index.php/dashboard/shopping_feed"]').closest('li').remove();
}
});
</script>
—
### ✅ Where to put it:
– **Option 1**: Inside your main dashboard view like `view.php`
– **Option 2**: Inside `admin-feed.js` (if you're registering it globally)
—
### 🔍 Summary:
| Condition | Action |
|————————————-|——————————-|
| On `/dashboard/store/overview` | ✅ Keep "Shopping Feed" menu |
| On any other dashboard page | ❌ Remove "Shopping Feed" menu |
Let me know if you want to remove multiple items based on similar logic.
—
## ✅ Step 1: Register the asset (you already did)
In your `on_start()` method:
$al->register('javascript', 'feed-admin-js', 'js/admin-feed.js', [], $this);
This registers the JS file located at:
packages/shopping_feed_manager/js/admin-feed.js
—
## ✅ Step 2: Require the asset **globally in the dashboard**
To include `feed-admin-js` on **every dashboard page**, you can use a dashboard-wide event listener like this:
use Events;
public function on_start()
{
$al = AssetList::getInstance();
// Register the JS file
$al->register('javascript', 'feed-admin-js', 'js/admin-feed.js', [], $this);
// Listen to view rendering
Events::addListener('on_before_render', function () {
$view = View::getInstance();
$req = Request::getInstance();
$path = $req->getPath();
// Only load in dashboard
if (strpos($path, '/dashboard') === 0) {
$view->requireAsset('javascript', 'feed-admin-js');
}
});
}
—
### ✅ Result
Your `feed-admin-js` will now load on:
– All pages under `/index.php/dashboard/*`
– Without manually requiring it in every view
—
### 🧠 Extra Tip: Combine with your logic
Now inside `admin-feed.js`, you can write your earlier logic:
$(function () {
const currentPath = window.location.pathname;
if (!currentPath.includes('/dashboard/store/overview')) {
$('a[href="/index.php/dashboard/shopping_feed"]').closest('li').remove();
}
});
Let me know if you also want to load the asset **on the front end** or restrict it to certain package pages.