Skip to content

Settings & Configuration Helpers

These helpers allow your theme to read configuration values set by administrators in the backend. Use them to make your theme responsive to admin panel changes without editing code.


settings(string $name): mixed

Fetches a global site setting by name from the admin panel. This is the simplest and most common way to read store-wide settings.

{{-- Display contact information --}}
<p>Phone: {{ settings('contact_phone') }}</p>
<p>Email: {{ settings('contact_email') }}</p>

{{-- Check a feature flag --}}
@if(settings('enable_reviews'))
    @include('partial.reviews')
@endif

{{-- Use in maintenance mode check --}}
@if(settings('maintenance_mode'))
    <div class="maintenance-banner">We are currently down for maintenance.</div>
@endif

theme_setting(string $context, ?string $key = null, mixed $default = null): mixed

Fetches a theme-specific setting by context and optional key. Theme settings are organized into context groups (e.g., 'colors', 'header').

{{-- Get a single key from a context --}}
@php $primaryColor = theme_setting('colors', 'primary_color', '#007bff'); @endphp

<style>
    .btn-primary { background-color: {{ $primaryColor }}; }
</style>

{{-- Get all settings for a context (returns an array) --}}
@php $headerConfig = theme_setting('header'); @endphp
@if($headerConfig && ($headerConfig['show_search_bar'] ?? false))
    @include('partial.searchbar')
@endif

theme_name(): string

Returns the name (slug) of the currently active theme.

{{-- Useful for debugging or conditional logic --}}
<!-- Active theme: {{ theme_name() }} -->

theme_site_id(): int

Returns the current site's numeric ID. Useful when constructing file paths manually.

@php $siteId = theme_site_id(); @endphp
<img src="/files/s{{ $siteId }}/assets/logo.png" alt="Logo">