Skip to content

Commit

Permalink
Make page resource configurable
Browse files Browse the repository at this point in the history
Update CHANGELOG

Co-authored-by: Harmen Janssen <[email protected]>

Updating changelog with correct versions
  • Loading branch information
HammenWS committed Jun 8, 2023
1 parent 0195b16 commit c4a5375
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Changelog

## Version 4.1.1
## Version 4.1.0

In our previous setup we told you can extend the `PageResource` to customize the flexible content
layouts. But this meant that the same 'page' resource was registered twice in Nova, which caused
several issues, like unable to customize global search behaviour.

You can still extend the `PageResource` to customize the flexible content layouts, but you should
configure it in the `nova-pages-tool.php` config file:

```php
'pageResourceClass' => \App\Nova\Page::class,
```

Update notes: In previous versions you had to disable the global search functionality on your extended
page resource, otherwise you got double search results. You can remove this disabling 'hack' now.

## Version 4.0.1

- Use the `FRONTEND_URL` environment variable to configure which URL will be
used to link to pages. Useful when you're using Nova as a headless CMS.
used to link to pages. Useful when you're using Nova as a headless CMS.

## Version 4.0.0

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ php artisan vendor:publish --provider="Grrr\Pages\ToolServiceProvider" --tag="co

Out of the box you will get a Pages tool in your Nova back-end to manage pages. If everything is to your liking, you can just start using it as-is!

However, you will probably want to add some layouts to be used in the flexible-content portion of the page.
You can create your own `Page` resource and extend `Grrr\Pages\Resources\PageResource`. Override the `getFlexibleLayouts()` method to specify your own flexible content layouts:
However, you will probably want to add some layouts to be used in the flexible-content portion of the page. Or customize some other properties.

In the configuration file `config/nova-pages-tool.php` you can tell it to use your own Nova resource and extend `Grrr\Pages\Resources\PageResource`. Override the `getFlexibleLayouts()` method to specify your own flexible content layouts:

```php
namespace App\Nova;
Expand Down
2 changes: 2 additions & 0 deletions config/nova-pages-tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// Disable for unilingual websites.
'allowTranslations' => true,

'pageResourceClass' => \Grrr\Pages\Resources\PageResource::class,

'templates' => [\Grrr\Pages\Models\Page::TEMPLATE_DEFAULT],
'defaultTemplate' => \Grrr\Pages\Models\Page::TEMPLATE_DEFAULT,

Expand Down
7 changes: 6 additions & 1 deletion src/PagesTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ class PagesTool extends Tool
*/
public function boot()
{
Nova::resources([PageResource::class]);
// Only register default PageResource class when there is no custom one configured.
if (
config('nova-pages-tool.pageResourceClass') === PageResource::class
) {
Nova::resources([PageResource::class]);
}
}

/**
Expand Down

0 comments on commit c4a5375

Please sign in to comment.