F
Filament5d ago
Abi

Page Titles for the different Resource Pages

Is there a function or an property on the Resource or Record Classes to customize what is displayed on the Page Titles? Currently it shows View {Resource Title} - {App Name} or Edit {Resource Title} - {App Name}. Is there a way to customize that?
8 Replies
Julien B. (aka yebor974)
Hi, on each resource page, you can define the title using the $title property or getTitle method:
protected static ?string $title = 'Test';
protected static ?string $title = 'Test';
public function getTitle(): string | Htmlable
{
return __('test_locale');
}
public function getTitle(): string | Htmlable
{
return __('test_locale');
}
Abi
AbiOP5d ago
when using the getTitle method, how do I identify the current state view/edit/create?
Julien B. (aka yebor974)
You need to define on each resource pages (Create, Edit, ...)., so you know the current state. You can't define it on master Resource class
Abi
AbiOP5d ago
ok, thank you @Julien B. (aka yebor974) , gave a try of what you suggested, don't think that is what I am looking at. when I mentioned page title, I met the meant <title> </title> of the resource page and not the title that shows below the breadcrumb
Julien B. (aka yebor974)
For example, if you make $title as "Test", the title attribute of your page becomes "Test - { Brand name of your panel}" What do you want as title ?
Abi
AbiOP5d ago
So I have different Job Types. Lets take for example a Design Job, so, when someone is viewing the Job, I want the Document title to be Viewing Design Job #XX, but the page title below the breadcrumb to be Design Job #XX. Does it make sense? Similarly for Editing..
Julien B. (aka yebor974)
if i understand you want a different value between the <h1> attribute (in breadcrumb) and the title of the page (<title></title>) For the breadcrumb title, define $heading attribute or redefine getHeading() method.
public function getTitle(): string
{
return 'Viewing Design Job #XX';
}

public function getHeading(): string
{
return 'Design Job #XX';
}
public function getTitle(): string
{
return 'Viewing Design Job #XX';
}

public function getHeading(): string
{
return 'Design Job #XX';
}
Abi
AbiOP5d ago
ah ok, let me try that. I din't know $heading was a thing. Thank you

Did you find this page helpful?