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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Module themes 2.4.0


Reply


4 Posts   1073 Views

Avatar
paul.mcilwaine

Community Member, 21 Posts

29 June 2010 at 1:02pm

I was previously using 2.3.4 of silverstripe with a theme that worked with a module that I created e.g.

mymodule

themes/mythemename_mymodule

However after upgrading to 2.4.0 the mythemename_mymodule no longer works (I rebuilt the project to see if this would fix it). However on my development machine all is fine and works as it should. The issue seems to be affecting my staging server and cannot figure out what the issue is. Ive rebuilt the project on my development machine and still works correctly so something is different on the staging server but unsure as to what.

Has anyone run into similar problems ? What I do know is the manifest-main file doesnt recognise the mythemename_mymodule directory at all which im scratching my head about as file permissions are fine.

Avatar
biapar

Forum Moderator, 435 Posts

29 June 2010 at 7:16pm

mythemename_mymodule works into 2.4, too. Error?

Avatar
paul.mcilwaine

Community Member, 21 Posts

30 June 2010 at 12:15pm

Ok Ive done some more testing, and Im really puzzled by why this is happening.

I checked the ManifestBuilder class with some basic tests to see what was happening on line 330 I added this

if ( isset( $templateManifest[$templateName]['themes'][$themeName][$templateType] ) ) var_dump( $templateManifest[$templateName]['themes'][$themeName][$templateType] );

To see if a template was already in the Manifest and if it was output what was currently in it. On my development machine this is the normal theme directory files shown (What I expected). On the staging server its the theme_module name. (Reverse order)

So what is happening is the theme is overwriting the theme_modulename template which is incorrect. I cant think of why the order is different on the staging server as the only difference is Linux is the staging server whilst the dev is a Mac. It was working perfectly prior to upgrading but cant find any major differences in the ManifestBuilder to make this kind of change, I havent made changes to the linux server either which could maybe show any reasons as to why.

Avatar
paul.mcilwaine

Community Member, 21 Posts

30 June 2010 at 12:42pm

Ok seems Ive fixed it for now, unsure how good a fix it is though.

public static function get_themes($baseDir = null, $includeSubThemes = false) {
      // If no base directory specified, the default is the project root
      if(!$baseDir) $baseDir = BASE_PATH . DIRECTORY_SEPARATOR . THEMES_DIR;
      $themes = array();
      if(!file_exists($baseDir)) return $themes;
      
      $cwd = getcwd();
      chdir( $baseDir );
      $files = glob( "*", GLOB_ONLYDIR );
      
      if ( $files )
      {
         foreach ( $files as $file )
         {
            $fullPath = $baseDir . DIRECTORY_SEPARATOR . $file;
            if(strpos($file, '.') === false && is_dir($fullPath)) {
               $include = $includeSubThemes ? true : false;
               if(strpos($file, '_') === false) {
                  $include = true;
               }
               if($include) $themes[$file] = $file;
            }
         }
      }
      chdir( $cwd );
      return $themes;
   }