GeniXCMS

Options Class

categoryAPI edit_calendar31 Mar 2026

Global Options & Settings Class


The Options class is the central repository for site-wide configurations in GeniXCMS. It manages the persistent storage and efficient retrieval of everything from core metadata (Site Name, E-mail) to granular plugin parameters and theme-specific settings.


⚡ Data Retrieval Patterns

Fetching configuration data must be efficient to ensure sub-second page loads. GeniXCMS provides two distinct retrieval pathways.

Options::v(string $key)

This is the High-Performance method. It retrieves values from the system's pre-loaded data object (internal cache), which is initialized during the core boot phase.

  • Best Use Case: Use this in themes and templates to avoid redundant database queries.
  • Example: <?= Options::v('site_name'); ?>

Options::get(string $key, bool $decode = true)

This method performs a Direct Database Query for the specified key.

  • Best Use Case: Use this when you need to ensure you have the most up-to-the-second value, or when fetching large JSON objects from modules.
  • Example: $raw_json = Options::get('my_module_config');

💾 Saving & Modifying Data

The Options engine supports both single-key updates and batch processing.

Options::update($input, $value = '')

The primary method for editing site configuration.

Scenario Input Type Usage Example
Single Key string Options::update('site_email', '[email protected]');
Batch Update array Options::update(['A' => '1', 'B' => '2']);

Options::insert(array $vars)

Dispatches multiple new options to the database simultaneously. Typically used during module installation or theme activation.


🔍 Validation & Existence

Before attempting to use or update a setting, you can verify its existence.

  • Options::isExist(string $key): Returns a bool indicating if the key is present in the database.
  • Options::validate(string $key): Checks if the key exists and has a non-empty value.

🏗️ Technical Method Summary

Method Role Return Type
v($key) Fetch from pre-loaded internal cache. mixed
get($key) Direct database retrieval. mixed
update() Modify existing option(s). bool
insert() Add multiple new options. bool
isExist() Check for key presence. bool

lightbulb
TipPerformance Hint: Always prioritize Options::v() within your theme's header.php or footer.php. This method allows GeniXCMS to serve the entire site configuration with zero additional SQL overhead after the initial boot.

See Also