1 (edited by mark0300 12/30/2016 11:54:53 am)

Topic: User Theme

Hi,

Is there a function that I could use to retrieve the current user's theme?

I have found user_theme(), but the value retrieve does not seem to be correct.

Here is the code:

include_once($path_to_root . "/includes/current_user.inc");

$themename=user_theme();

if ($themename=='dashboard')
{

echo "this is dashboard";

}
else
{
echo "this is not dashboard";
}


Could someone advise?

Thank you.

/Mark

Re: User Theme

You need to be logged in as the said user before it can get it.

The said function is defined in lines 489-493 of includes/current_user.inc

function user_theme()
{
    return isset($_SESSION["wa_current_user"]) ?
        $_SESSION["wa_current_user"]->prefs->get_theme() : 'default';
}

Re: User Theme

Thanks  @APMuthu.

I actually added it to lang/installed_languages.inc to lang/installed_languages.inc as follows.  But it does not work since the language is used before a user is logged in, therefore the user_theme() does not work here. The reason of using the user_theme() is when dashboard theme is used and the encoding is utf-8, some of the wordings (legends, headers) on the charts or tables disappeared.  The missing wordings will show up when the encoding is set to "iso-8859-1".  Would you suggest any other work around where I could use utf-8 to handle my chinese character inputs and it does not affect the dashboard charts...  Thank you.


include_once($path_to_root . "/includes/current_user.inc");


//$themename=user_theme();
$themename="dashboard";

if ($themename=='dashboard')
{
$encoding_0="iso-8859-1";
//$encoding_0="utf-8";
}
else
{
$encoding_0="utf-8";
//$encoding_0="iso-8859-1";
}


$installed_languages = array (
  0 =>
  array (
    'code' => 'C',
    'name' => 'English',
    'encoding' => $encoding_0,   

  ),

Re: User Theme

You can use either a hard coded approach (Quick and Dirty) or change the encoding of all the php files to be in the utf-8 character set.