Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding an extra DB field disables translations tab

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

Page: 1
Go to End
Author Topic: 701 Views
  • Hypnus
    Avatar
    Community Member
    11 Posts

    Adding an extra DB field disables translations tab Link to this post

    Hi,

    I'm kind of a newbie and maybe my question is dumb but i can't find a solution for my problem.
    I am trying to translate my site but when i extend my Page class with an extra field and add it to the CMSFileds the Translations tab disappears from the CMS, and I cannot translate the page.
    I've added the translations method _t() to the label of the field but still nothing.

    I am using SilverStripe 2.4.3 with MYSQL and what I've setup:

    My config file has:
    -------------------------- _config.php --------------------------------------------------------
    // Enable Translatable
    Object::add_extension('SiteTree', 'Translatable');
    Object::add_extension('SiteConfig', 'Translatable');

    // Default locale language
    Translatable::set_default_locale("en_US");

    // Enable locale
    i18n::enable();
    // Set the default site locale
    i18n::set_locale('en_US');

    // Define allowed locales overriding those present in i18n::$common_locales
    global $allowed_locales;
    $allowed_locales = array(
    'en_US' => array('English', 'English'),
    'de_DE' => array('German', 'Deutsch')
    );
    i18n::$common_locales = $allowed_locales;
    ------------------------------------------------------------------------------------------------------

    I've added to my Page.php in the controller init function and the extension:
    --------------------------------- Page.php --------------------------------------------------------
    public static $extensions = array(
       "Translatable"
    );

    ...... Page_Controller.....

    if($this->dataRecord->hasExtension('Translatable')) {
    i18n::set_locale($this->dataRecord->Locale);
    }

    ------------------------------------------------------------------------------------------------------

    Thanks in advance.

  • Hypnus
    Avatar
    Community Member
    11 Posts

    Re: Adding an extra DB field disables translations tab Link to this post

    Ok, i was wrong with the last reply, the issue is with the disable/enable the CMSFieldsExtension :

    So do not use something like this (in the getCMSFields() method, but not only there):

    SiteTree::disableCMSFieldsExtensions();
    $fields = parent::getCMSFields();
    SiteTree::enableCMSFieldsExtensions();

    just simply:

    $fields = parent::getCMSFields();

    will do it just fine.

    Thanks and sorry if i got anyone confused.

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