fab_gu Posted April 27, 2020 Posted April 27, 2020 Would it be possible to auto select a theme based on the user language?
BomAle Posted April 28, 2020 Posted April 28, 2020 (edited) $settings = ['it' => 12, 'en' => 1]; foreach ( $settings as $k => $v ) { if( $this->member->skin !== $v AND \strtolower( \substr( $this->member->language()->short, 0, 2 ) ) === $k ) { $this->member->skin = $v; if( $this->member->member_id ) { $this->member->save(); } } } return call_user_func_array( 'parent::getTheme', func_get_args() ); but this code is valid only if you overload \IPS\Session\Front::getTheme With switchTheme the theme is set only for current location, with getTheme overload you can set it permanently only once occur preventing more call or redirection (like a silent code that automatically cover default IPS code and your needs) Edited April 28, 2020 by BomAle data['theme_id'] only affect ajax call...
BomAle Posted April 28, 2020 Posted April 28, 2020 $settings = ['it' => 12, 'en' => 1]; foreach ( $settings as $k => $v ) { if( $this->member->skin !== $v AND \strtolower( \substr( $this->member->language()->short, 0, 2 ) ) === $k ) { $this->member->skin = $v; if( $this->member->member_id ) { $this->member->save(); } return NULL; } } return call_user_func_array( 'parent::getTheme', func_get_args() ); this will work for sure (return NULL prevent resetting to default theme see system/Theme/Theme.php:284)
Recommended Posts