Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to change displayed page type name in admin panel based on current language?

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

Page: 1
Go to End
Author Topic: 1185 Views
  • MitraX
    Avatar
    Community Member
    20 Posts

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

    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).

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: How to change displayed page type name in admin panel based on current language? Link to this post

    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

  • MitraX
    Avatar
    Community Member
    20 Posts

    Re: How to change displayed page type name in admin panel based on current language? Link to this post

    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') ;)

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: How to change displayed page type name in admin panel based on current language? Link to this post

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

    Good luck MitraX

    1185 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.