Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » Where can i change the names of templates?

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

Page: 1
Go to End
Author Topic: 1295 Views
  • steffik
    Avatar
    Community Member
    15 Posts

    Where can i change the names of templates? Link to this post

    I have developed some custom templates like "Application Page" or "Home Page". Now I'd like to rename their titles so that they show correctly in my language "Anwendungsseite" or "Startseite.

    How can this be done?
    Where would i have to look?

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Where can i change the names of templates? Link to this post

    It's available as an option within the Page edit form, then Content tab --> Meta data tab --> Title
    (save & publish)

  • steffik
    Avatar
    Community Member
    15 Posts

    Re: Where can i change the names of templates? Link to this post

    Thank you

    But that was not exactly my question. I wanted to change the title that appears on the left column when you create a new page with a given template. I thought there would be some kind of language file where i could define these names but i didn't find it. I know sapphire (or the cms) creates the names from the names of the files so i:

    - copied my template files and renamed the copys with the new name
    - then i made all existing sites use the new templates
    - after that i deleted the old templates and also a few db tables that didn't get correctly deleted

    Now at least i have the correct name, but only in English - what i wanted was, have the name in German as well ;)

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Where can i change the names of templates? Link to this post

    Are you using the translatable?
    When enabled that allows for pages to be translated and all content (including titles) can be locale specific

  • steffik
    Avatar
    Community Member
    15 Posts

    Re: Where can i change the names of templates? Link to this post

    Thank you - i'll definitely look into that

  • t|m
    Avatar
    Community Member
    19 Posts

    Re: Where can i change the names of templates? Link to this post

    Hi Steffi,

    try putting

    static $singular_name = "My super Page";

    in your pages

    Cheers

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Where can i change the names of templates? Link to this post

    When creating a new page in the cms, it will appear in the sitetree on the left, named something like 'new MySpecialPagetype' or 'neue MySpecialPagetype'... That had been bothering me for a while.

    First, to translate a custom pagetype to a proper name, place this in your languagefile mysite/lang/de_DE.php:

    $lang['de_DE']['MySpecialPagetype']['SINGULARNAME'] = 'German name for this pagetype';

    This will translate the entries in the Create Page dropdown, but still won't work for the name generated for new pages in the SiteTree. But now you can, in your mysite/code/page.php Page class, something like this:

    function onBeforeWrite(){
       parent::onBeforeWrite();
       if (empty($this->ID)) {
          $this->Title = _t('CMSMain.NEW', 'new') . ' ' . $this->i18n_singular_name();
       }
    }

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