Jump to content

Community

Automatically assign a theme based on selected language


Recommended Posts

$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 by BomAle
data['theme_id'] only affect ajax call...
Link to post
Share on other sites
$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)

1FyW5wY.png

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy