This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

gergo85
gergo85

I would like to get the "locale" (or other) preference value from backend_user_preferences table. What is the easiest way? Sorry for beginning question, but I've just discovered the October CMS.

Blackpig Creative
Blackpig Creative

Are you using the RainLab.Translate plugin?

Try this:

Use App;
Use RainLab\Translate\Classes\Translator;
private function getCurrentLocale() {

   if (class_exists('RainLab\Translate\Classes\Translator')) {
        $translator = Translator::instance();
        return $translator->getLocale();
    }

    return App::getLocale();
}

Last updated

gergo85
gergo85

I added a new option in Settings -> My settings -> Back-end preferences, and I would like to get value of this new option in the _settings_menu_items.htm file.

gergo85
gergo85

Finally I found the solution:

    use Backend\Models\UserPreferences;
    $preferences = UserPreferences::forUser()->get('backend::backend.preferences');

Thank you for helping me!

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.