Skip to content

Commit 4637dd4

Browse files
committed
Add menu seeder helper.
Add menu docs.
1 parent 4784141 commit 4637dd4

File tree

6 files changed

+629
-171
lines changed

6 files changed

+629
-171
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ phpstan.neon
3030
testbench.yaml
3131
/docs
3232
/coverage
33+
34+
# Claude Code Instructions
35+
CLAUDE.md
36+
.claude

CLAUDE.md

Lines changed: 0 additions & 161 deletions
This file was deleted.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ renders web pages that can be easily extended and styled.
1313
Other features that will be provided:
1414
- Pages with hero, slugs, content blocks, publication options and SEO fields.
1515
- Website: routing, blade views, CSS themes included.
16+
- Menu builder with customisable blade templates
1617
- Extendable settings model and Filament resource to store CMS settings and images.
1718
- Redirect support for when slugs are renamed
1819
- Sitemap generation
@@ -117,6 +118,90 @@ The package contains a pre-configured panel. You can register the panel in the `
117118

118119
If you want you can build your own panel from the provided resources.
119120

121+
## Menu builder
122+
123+
The package includes a powerful hierarchical menu builder with a drag-and-drop interface for creating navigation menus. Menus support multiple types of links and can be easily styled with custom templates.
124+
125+
### Features
126+
127+
- **Hierarchical structure** - With configurable max depth per menu
128+
- **Multiple link types** - Internal routes, external URLs, and linkable models (Pages or your own project model)
129+
- **Drag & drop management** - Intuitive tree interface for reordering and nesting items
130+
- **Multiple menu styles** - Default, horizontal, vertical, and dropdown templates included
131+
- **Translation support** - Multilingual menu labels with locale-aware URLs
132+
- **Conditional visibility** - Show/hide menu items without deleting them
133+
- **Icon support** - Optional icons for menu items (basic implementation currently)
134+
- **Dynamic labels** - Use model titles or custom labels for linked content
135+
136+
### Adding linkable models
137+
138+
To make your models available in the menu builder, add them to the configuration:
139+
140+
```php
141+
// config/filament-flexible-content-block-pages.php
142+
'menu' => [
143+
'linkable_models' => [
144+
\App\Models\Page::class,
145+
\App\Models\Product::class,
146+
\App\Models\Category::class,
147+
],
148+
],
149+
```
150+
151+
Your models should implement the `HasMenuLabel` contract:
152+
153+
```php
154+
use Statikbe\FilamentFlexibleContentBlockPages\Models\Contracts\HasMenuLabel;
155+
156+
class Product extends Model implements HasMenuLabel
157+
{
158+
public function getMenuLabel(?string $locale = null): string
159+
{
160+
return $this->getTranslation('name', $locale ?? app()->getLocale());
161+
}
162+
}
163+
```
164+
165+
If you are using the Flexible Content Blocks title trait in your model, you can implement `HasMenuLabel`
166+
easily with [`HasTitleMenuLabelTrait`](src/Models/Concerns/HasTitleMenuLabelTrait.php).
167+
168+
### Customizing menu styles
169+
170+
The package includes several built-in menu styles, but you can easily add your own:
171+
172+
1. **Add new styles to config:**
173+
```php
174+
// config/filament-flexible-content-block-pages.php
175+
'menu' => [
176+
'styles' => [
177+
'default',
178+
'horizontal',
179+
'vertical',
180+
'dropdown',
181+
'mega', // Your custom style
182+
],
183+
],
184+
```
185+
**Tip:** Add translations if you want UX-friendly style dropdowns.
186+
187+
2. **Create the template files:**
188+
```bash
189+
# Main menu template
190+
resources/views/vendor/filament-flexible-content-block-pages/tailwind/components/menu/mega.blade.php
191+
192+
# Menu item template
193+
resources/views/vendor/filament-flexible-content-block-pages/tailwind/components/menu/mega-item.blade.php
194+
```
195+
196+
3. **Use in your templates:**
197+
```blade
198+
<x-flexible-pages-menu code="header" style="mega" />
199+
```
200+
201+
The style can also be configured in the database model, then you can skip the `style` attribute.
202+
203+
See the [menu seeding documentation](documentation/seeders.md) for programmatic menu creation.
204+
120205
## Configuration
121206

122207
TODO

0 commit comments

Comments
 (0)