Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to change displayed page type name in admin panel based on current language?


Go to End


4 Posts   4834 Views

Avatar
MitraX

Community Member, 20 Posts

12 July 2011 at 9:01pm

I have a question regarding selecting page type name during a page creation.

Let's say that a site is configured for using multi language logic and we need to create a structure in English and German language. When a user from England creates a page there is an option for selecting page type and the type name is created based on the class name, e.g. HomePage will be listed as "Home", ArticlePage will be listed as "Article" etc.

A scenario that I am trying to create is to change displayed page type based on selected language. So, if a user from Germany wants to create an article page in German, he/she should be able to select "Artikel" page type instead of "Article", "Start" instead "Home" page type...

Of course, this should be done without duplicating classes with the same functionality and changing their names only.

I checked documentation but didn't find any property that could be used for this logic. I am not even sure whether is this possible but I would appreciate if someone has a suggestion(s).

Avatar
Invader_Zim

Community Member, 141 Posts

12 July 2011 at 10:14pm

Hi MiraX.

Maybe you could use something like this in your PageTypes:

...
static $singular_name = _t('YourPageType.SINGULARNAME', 'Page Type');
static $plural_name = _t('YourPageType.PLURALNAME', 'Page Types');
...

and create the lang files accordingly in your /mysite/lang directory, e.g. like this:

//in en_US.php
$lang['en_US']['YourPageType']['SINGULARNAME'] = 'Page Type';

//in de_DE.php
$lang['de_DE']['YourPageType']['SINGULARNAME'] = 'Seitentyp';//oder so :-)

Note, this is just an idea.
I can't test it, since I'm not on my machine right now and there might be a lot of typos or I might be totally wrong with my idea :-)

Cheers
Christian

Avatar
MitraX

Community Member, 20 Posts

12 July 2011 at 10:54pm

Edited: 12/07/2011 10:59pm

Thank you, Invader.

I think it will do the job. In the meantime I have found the similar sample in the book "SilverStripe: the complete guide to CMS development" and in the topic http://silverstripe.org/general-questions/show/8689 . I will try later and let you know if it's fixed. And.. MitraX (with 't') ;)

Avatar
Invader_Zim

Community Member, 141 Posts

12 July 2011 at 11:35pm

And.. MitraX (with 't') ;)
Uhhh, sorry for that...shame on me

Good luck MitraX :-)