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.

Archive

Our old forums are still available as a read-only archive.

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

Translatable Fatal error


Go to End
Reply

18 Posts   8788 Views

Avatar
hitautodestruct

9 January 2008 at 1:08am Community Member, 19 Posts

Hey there anyone that can help.

I have managed to get my site up and running with custom fields and templates.
So now the only thing thats stopping me from implementing my Silverstripe site and the main reason for choosing this framework is the Translatable option.

It seems that every time I enable the:

static $extensions = array("Translatable('CustomField')");


For one or many of my custom fields I get a dramatic Fatal Error.

I have tried everything to no avail.
Can anyone help me with this?

SilverStripe ver. 2.2.1
Apache, MySQL and PHP5
Are all according to stats.

This is the code for my HomePage.php Pagetype:

<?php
class HomePage extends SiteTree {
   static $db = array(
      'Slogan' => 'Varchar'
   );

//This is the code I insert that causes all the problems
   static $extensions = array(
      "Translatable('Slogan')"
   );

static $has_one = array(
);

   static $defaults = array(
   );

      function getCMSFields() {
         $fields = parent::getCMSFields();

         $fields->addFieldToTab('Root.Content.Main', new TextField('Slogan', 'The slogan text under the rummy royal logo:'), 'Content');

    return $fields;
   }
}

class HomePage_Controller extends ContentController {
   function init() {
      parent::init();
      Requirements::themedCSS("RummyStyle");
   }
}
?>

I attached the error page to this post as well.

Avatar
yitter

21 January 2008 at 2:49pm Community Member, 10 Posts

Just wanted to say, I have the exact same problem. Anyone has suggestions on how to solve this? Is it a Bug?

Avatar
Ingo

26 January 2008 at 6:34pm Forum Moderator, 801 Posts

hm this might be a bug in the translation system - can you try re-setting all $extensions in your subclass? see sapphire/core/model/SiteTree.php $extensions array.

Avatar
hitautodestruct

28 January 2008 at 1:55am Community Member, 19 Posts

Hey Ingo
Thanks for the reply but I have gone about a different way of setting up translating my site.
I now have a duplicated HomePage and Page page types with a different language prefix for each language.
Example:
german is de-home,
spanish is: es-home etc.

This is also more SEO compatible since the search engine does not recognize the ?lang= attribute and can't index the other language pages.

I have messed around way to much with the translation system and all it did was cause me trouble. So, I'm not going to test out anything else.

But on the plus side I'm still using SS for the purpose I initially intended it for, which is a multi-language site.

Avatar
Ingo

28 January 2008 at 7:50am Forum Moderator, 801 Posts

fair enough, thanks for your patience. we're just bulding our first commercial applications with the translation system as well (it was built by a google summer of code student), so its still a fairly young component of Silverstripe.

Avatar
yitter

8 February 2008 at 1:51am (Last edited: 8 February 2008 1:51am), Community Member, 10 Posts

well messing with the translation system also got me into trouble. You mentioned to re-set all extensions in the Page class, I did it like that:

class Page extends SiteTree {
...
/* this is just copied from SiteTree*/
static $extensions = array(
      "Hierarchy",
      "Translatable('Title', 'MenuTitle', 'Content', 'URLSegment', 'MetaTitle', 'MetaDescription', 'MetaKeywords', 'Status', 'ExtraMeta')",
      "Versioned('Stage', 'Live')"   
   );
...
}

I'm not sure if this is a real re-set but the problem is still the same: Adding Custom Fields to the Translateable causes serious errors. But when doing the same in the Site Tree Class (new Custom field etc.) I can add it to the $extensions Translateable array .... Strange enough?!

But if I now try to Translate a Page only the original Site Tree Fields can be translated, the new Field is only viewable (not editable) and I can't find any reason why that is. It is strange ...

Any suggestions?

Avatar
Ingo

8 February 2008 at 9:31am Forum Moderator, 801 Posts

we've got a fix in one of our project branches, which matt will merge back to trunk soon (~ 2 weeks). basically we're defining translatable-fields on a new static in the SiteTree class instead, and have cleaned up the DataObjectDecorator logic a bit.

Avatar
yitter

8 February 2008 at 10:54am Community Member, 10 Posts

that sounds very good, can't wait to see that fix working!
Thats for the great work btw.

cheers

Go to Top