Skip to content

Commit

Permalink
Merge pull request #34 from oddvalue/patch-1
Browse files Browse the repository at this point in the history
Exclude pages where `shouldRegisterNavigation()` is false
  • Loading branch information
pxlrbt authored Jan 3, 2024
2 parents 223b49c + 1c9d8d7 commit 6d8bbb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ CMD + /

This plugin relies on the same properties and methods used for Filament's global search. For records showing up with the correct name in "Edit/View" you need to set `$recordTitleAttribute`. [Check the docs for more information](https://filamentphp.com/docs/2.x/admin/resources/global-search)

#### Excluding pages

If you need to exclude a page from the spotlight results you may do so by adding a static `shouldRegisterSpotlight` method to the page and return false:

```php
public static function shouldRegisterSpotlight(): bool
{
return false;
}
```

This can be useful when you have pages that require URL parameters.

## Translation

To translate or edit the default placeholder, you have to publish the translation file for *wire-element/spotlight*:
Expand Down
4 changes: 4 additions & 0 deletions src/Actions/RegisterPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static function boot(Panel $panel)
*/
$page = new $pageClass();

if (method_exists($page, 'shouldRegisterSpotlight') && $page::shouldRegisterSpotlight() === false) {
continue;
}

$name = collect([
$page->getNavigationGroup(),
$page->getTitle(),
Expand Down

0 comments on commit 6d8bbb2

Please sign in to comment.