#Implementing tabs that changes the whole page

36 messages · Page 1 of 1 (latest)

surreal gull
#

How do I implement a tab that will change the whole page and set the url?

The current setup of that is that you can click multiple tabs without affecting the url.
In my case I have a lots of tabs and some tabs contains tables and I don't want the page to load all the contents of those tabs in one go as it will severely affect the resource and performance on the server.

Please see the demo

#

So as you see on the demo the tab is set and it only loaded that contents on the selected tab which is what I wanted to implement here.

surreal gull
#

Hi, Morty would it be okay if you could guide me through this?

opaque swan
#

I've got my own projects I'm working on but if you post in here I'll help when I can.

#

This is what you're looking for, right?

surreal gull
#

YES something like that, what happens if you click on the contact, will the whole page reload and load only the the contents inside the "Contacts" Tab?

opaque swan
#

Yes, it's loading a manage related records page but you can also just do custom pages.

surreal gull
#

@opaque swan in my current setup do you recommend me to use Resource or Custom pages ?

opaque swan
#

You can mix-and-match. I can't really answer that for you because I don't know your project. If your tabs will be related records to the resource record then use manage related records pages. Otherwise you might need custom pages.

surreal gull
#

I added a custom page called SettingAccountDetails.php

however I have trouble adding this SettingAccountDetails as a Navigation tab under Setting.php
What should be the right way for calling custom page as a tab?

surreal gull
#

Please guide me as I am not even sure if I am doing these steps correctly or should I create a Settings Resource instead ?

opaque swan
#

ya it's sub-resource navigation. Is setting related to the user resource in that screenshot? If not, I think you'd need to create a setting resource.

#

Some code that might help you:

class AccountResource extends Resource
{
    protected static ?string $model = Account::class;

    protected static ?string $recordTitleAttribute = 'name';

    protected static ?int $navigationSort = 1;

    protected static ?string $navigationGroup = 'Resources';

    protected static ?string $navigationIcon = 'heroicon-o-home-modern';

    protected static ?string $navigationLabel = 'Accounts';

    protected static SubNavigationPosition $subNavigationPosition = SubNavigationPosition::End;

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListAccounts::route('/'),
            'view' => Pages\ViewAccount::route('/{record}'),
            'contacts.index' => Pages\ManageAccountContacts::route('/{record}/contacts'),
            'fields.index' => Pages\ManageAccountFields::route('/{record}/fields'),
            'files.index' => Pages\ManageAccountFiles::route('/{record}/files'),
            'notes.index' => Pages\ManageAccountNotes::route('/{record}/notes'),
            'tickets.index' => Pages\ManageAccountTickets::route('/{record}/tickets'),
        ];
    }

    public static function getRecordSubNavigation(Page $page): array
    {
        return $page->generateNavigationItems([
            Pages\ViewAccount::class,
            Pages\ManageAccountContacts::class,
            Pages\ManageAccountFields::class,
            Pages\ManageAccountFiles::class,
            Pages\ManageAccountNotes::class,
            Pages\ManageAccountTickets::class,
        ]);
    }
}
#
class ViewAccount extends ViewRecord
{
    protected static string $resource = AccountResource::class;

    protected static ?int $navigationSort = 1;

    protected static ?string $navigationIcon = 'heroicon-o-identification';

    protected static ?string $navigationLabel = 'Details';

    protected static ?string $breadcrumb = 'Details';

    protected static ?string $title = 'Account Details';

    protected ?string $heading = 'Account Details';
}
#
class ManageAccountContacts extends ManageRelatedRecords
{
    protected static string $resource = AccountResource::class;

    protected static string $relationship = 'contacts';

    protected static ?int $navigationSort = 2;

    protected static ?string $navigationIcon = 'heroicon-o-user-group';

    protected static ?string $navigationLabel = 'Contacts';

    protected static ?string $breadcrumb = 'Contacts';

    protected static ?string $title = 'Account Contacts';

    protected ?string $heading = 'Account Contacts';
}
surreal gull
#

Why is it when I tried adding a new Resource, the new For example resource SettingResource does not even show on the left side navigation?
as Setting ?

lone fox
surreal gull
surreal gull
surreal gull
#

@opaque swan I followed your implementation on the navigation but I think I am missing something here in order to display the pages that I wanted under this resource.

opaque swan
#

I'm not really following your settings example. Resource sub-navigation is done for each record of a resource.

Perhaps you should be putting your sub-nav on the user resource from what it appears you're trying to achieve. Therefore when you click into a user you'd see the sub-nav.

surreal gull
opaque swan
#

I'm using clusters for my categories like so. You can change the position to the top with these too

surreal gull
#

I will try clusters this time,
The Settings structure in the model is quite different

opaque swan
#

I watched the video you linked again. From what I gather, this is how it's structured:

There is a Group resource. The group that you're working with is called 000 Jeff's Test Group. Therefore if you want to replicate this in Filament, you'd have a GroupResource listing and upon clicking into the 000 Jeff's Test Group record, then the resource subnav would be on that specific record, not the model.

surreal gull
opaque swan
#

The demo app has a cluster demo