Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Director:addRules generates a Class not found error - Silverstripe 2.3 rc3

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

Page: 1
Go to End
Author Topic: 2033 Views
  • danbalbo
    Avatar
    Community Member
    6 Posts

    Director:addRules generates a Class not found error - Silverstripe 2.3 rc3 Link to this post

    Hello to everyone,
    i am building a web multi language website on Silverstripe 2.3 release candidate 3 and i am getting this error:

    Fatal error: Class 'MultiLanguage' not found in /var/www/northstargroup/sapphire/core/control/Director.php on line 259

    I am following this how to avaibile on silverstripe help http://doc.silverstripe.org/doku.php?id=recipes:multilingual_content&s=multilingual

    MultiLanguage Class is under mysite directory and here is the code:

    class MultiLanguage extends ModelAsController {   
       static $lang;   
       
       function init() {
          $baseUrl = Director::baseUrl();
          $requestUri = $_SERVER['REQUEST_URI'];
          $lang = substr($requestUri, strlen($baseUrl), 2);      
          self::$lang = $lang;
          //prevents default behaviour of redirecting to '/' for '/en/'
          if($this->URLParams['URLSegment'] == "" || $this->URLParams['URLSegment'] == 'home') {
             $urlparams = array('URLSegment' => 'home', 'Action' => ' ');
             $this->setURLParams($urlparams);
          }      
          parent::init();
       }
       
       static function currentLang() {
          return self::$lang;
       }
       
       protected function getField($field) {      
          //$lang = $this::currentLang();
          $lang = "en";
          $langField = $field.'_'.$lang;
          if(isset($this->record[$langField])) {
             return $this->record[$langField];
          } else {
             return isset($this->record[$field]) ? $this->record[$field] : null;
          }
       }   
    }

    In my _config file i have added this:

    //
    Director::addRules(100, array(
       'en/$URLSegment/$Action/$ID/$OtherID' => 'MultiLanguage'
    ));

    but i am getting a Fatal error when i try to access pages like "domain.com/en/page-name" ( no problems with "domain.com/page-name" )

    Any idea about it?

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