Voyager 2
2.x
2.x
  • Introduction
  • Javascript
  • Media Manager
  • Plugins
  • Settings
  • bread
    • Actions
    • BREAD Builder
    • Layouts
    • Lists
    • Manipulate data
    • Multilanguage
    • Relationships
    • Validation
    • Views
  • contributing
    • Assets
    • CSS
    • Introduction
  • de
    • index
  • formfields
    • Checkboxes
    • Date & Time
    • Dynamic input
    • Formfields
    • Media Picker
    • Number
    • Password
    • Radios
    • Relationship
    • Repeater
    • Select
    • Simple array
    • Slider
    • Slug
    • Tags
    • Text
    • Toggle
  • getting-started
    • Installation
    • Prerequisites
    • Tips and tricks
    • What is Voyager
  • overriding
    • Overriding formfields
    • Icons
  • plugins
    • Assets
    • Components
    • Features
    • Filter
    • Plugin development
    • Language
    • Menu Items
    • Custom pages
    • Preferences
    • Routes
    • Settings
    • Widgets
Powered by GitBook
On this page

Was this helpful?

  1. plugins

Preferences

A plugin can store and access preferences which are stored on the filesystem. To write a preferences, simply call

// Not translatable
$this->preferences->set('my_key', 'My value');

// Translatable
$this->preferences->set('my_key', 'My value', 'en');
$this->preferences->set('my_key', 'Mein Wert', 'de');

inside your plugin class. To get a preference, call:

$this->preferences->get('my_key', 'Default value');

If your preference is translatable, it will be automatically translated to the current locale. If you don't want your value to be translated, simply pass false as the third parameter or the locale to translate it to another locale.

Clearing preferences

You can delete one preference by calling $this->preferences->remove('my_key'); or clear all preferences by calling $this->preferences->removeAll();

PreviousCustom pagesNextRoutes

Last updated 3 years ago

Was this helpful?