For the complete documentation index, see llms.txt. This page is also available as Markdown.

Custom Twig Slider

The Slider block's "Custom Twig (Advanced)" layout lets you create a fully custom hero/slider section featuring your products.

Overview

When "Custom Twig (Advanced)" is selected:

  • Content fields appear (title, value, subtitle, subvalue)

  • A featured image uploader appears

  • A code editor appears for your custom HTML + Twig template

  • Slider enabled products are automatically passed to your template

How to Use

  1. In the admin panel, edit the homepage

  2. Add or edit a Slider block

  3. In the "Slider Style" dropdown, select "Custom Twig (Advanced)"

  4. Optionally upload a featured image

  5. Fill in the content fields (title, value, subtitle, subvalue)

  6. Write your HTML + Twig code in the code editor

  7. Save and preview

Available Variables

Block Content

Variable
Type
Description
Example

title

string

Main headline

"Win Big"

value

string

Value/amount text

"£50,000"

subtitle

string

Secondary headline

"This Week's Prize"

subvalue

string

Secondary value

"Cash Alternative"

featured_image_url

string

Uploaded image URL

Full URL or empty

Products

Slider enabled products are automatically included. Loop through them with:

Product Fields:

Field
Type
Description
Example

product.id

int

Product ID

123

product.title

string

Competition name

"Win a BMW M3"

product.slug

string

Product URL slug

"win-a-bmw"

product.subtitle

string

Optional subtitle

"Limited Edition"

product.url

string

Product page link

"/product/win-a-bmw"

product.image_url

string

Featured image URL

Full URL

product.slider_image_url

string

Slider/hero image URL

Full URL

product.portrait_image_url

string

Portrait image URL

Full URL or null

product.featured_video_url

string

Featured video URL (if uploaded)

Full URL or null

product.video_embed_url

string

Player address for the Video URL, or null

"https://player.vimeo.com/video/..."

product.video_embed_type

string

"iframe" (YouTube or Vimeo) or "video" (video file), or null

"iframe"

product.video_embed_mime_type

string

File type for a video file, otherwise null

"video/mp4"

product.video_embed_orientation

string

"portrait" (YouTube Shorts) or "landscape", or null

"landscape"

product.price

string

Current price (formatted)

"£1.99"

product.price_raw

float

Current price as a number

1.99

product.price_display

string

Pretty current price (shows "Free" or "50p" for small amounts)

"£1.99"

product.original_price

string

Original price if on sale

"£2.99"

product.original_price_raw

float

Original price as a number (for calculations)

2.99

product.is_on_sale

bool

Whether on sale

true/false

product.is_free

bool

Whether the product is free to enter

true/false

product.has_question

bool

Whether an entry question is set

true/false

product.question

string

The entry question text, if any

"What colour is the sky?"

product.cash_alt

string

Cash alternative

"£50,000"

product.cash_alt_raw

float

Cash alternative as a number

50000

product.draw_date

string

Human readable draw date

"Draw On Mon Jan 5th 7:00pm"

product.end_date

string

Human readable end date

"Today 7:00pm"

product.start_date_raw

string

ISO start date (Y-m-d H:i:s)

"2026-01-01 09:00:00"

product.start_date

string

Human readable start date

"Tomorrow 9:00am"

product.start_date_seconds

int

Seconds until the competition opens (0 once open)

0

product.has_started

bool

Whether the start date has passed

true

product.draw_date_raw

string

Draw datetime (Y-m-d H:i:s)

"2026-01-05 19:00:00"

product.end_date_raw

string

End datetime (Y-m-d H:i:s)

"2026-01-05 19:00:00"

product.draw_date_seconds

int

Seconds until draw

86400

product.end_date_seconds

int

Seconds until end (for countdown)

3600

product.max_tickets

int

Total tickets available

5000

product.sold_tickets

int

Tickets sold

3421

product.tickets_remaining

int

Tickets left to sell

1579

product.percent_sold

float

Percentage sold

68.4

product.max_per_user

int

Max tickets per user (0 means no limit)

50

product.instant_wins

int

Number of instant wins

5

product.instant_wins_remaining

int

Remaining instant wins not yet won

3

product.game_type

string

Type of game

"standard"

product.winner_qty

int

Number of winners

1

product.simple_max_ticket

bool

Whether the product shows percentage sold only

true/false

product.has_ended

bool

Whether competition ended

true/false

product.is_sold_out

bool

Whether the product is sold out

true/false

product.is_active

bool

Whether the product is active

true/false

product.is_featured

bool

Whether the product is in the slider

true/false

product.auto_draw

bool

Whether the draw happens automatically

true/false

product.leaderboard_enabled

bool

Whether the product has a leaderboard

true/false

product.category

string

First category name

"Cars"

product.categories

array

All category names

["Cars", "Featured"]

product.description

string

Product description

"Win this amazing..."

product.gallery

array

Array of gallery image URLs

["https://...", "https://..."]

The slider only includes competitions that have reached their start date, so product.has_started is always true here. Scheduled competitions join the slider automatically once they open.

Dynamic Components

Countdown Timer

Progress Bar

This example demonstrates a modern, fully-featured single-slide carousel with all dynamic components, site theming, and interactive elements.

Common Splide Options:

Option
Description
Example

type

Slide type

"loop", "slide", "fade"

perPage

Slides visible

3

gap

Space between slides

"1rem", "20px"

autoplay

Auto-advance slides

true

interval

Autoplay delay (ms)

4000

pauseOnHover

Pause on mouse hover

true

arrows

Show prev/next arrows

true

pagination

Show dot navigation

true

breakpoints

Responsive settings

See example above

Tips

  1. Slider enabled products only - The slider automatically shows products enabled for the slider in the admin

  2. Use the first product - Access with products|first for a single hero product

  3. Handle empty state - Always check {% if products|length > 0 %} before displaying

  4. Use countdown timers - Add live countdowns with raffleCountdown(product.end_date_seconds)

  5. Featured image - Upload a background image and use {{ featured_image_url }}

  6. Use SplideJS with Alpine.js - Initialize with x-data x-init="new Splide($el, {...}).mount()"

  7. Use site colours - Access via {{ settings.primary_color }}, {{ settings.background }}, {{ settings.button_text_color }}

  8. Mobile responsive - Always include @media queries with reduced padding (24px/12px) to fit more above the fold


AI Context

For AI Assistants: This documents the RaffleX Slider block's Twig layout for creating custom slider sections.

Block Location: Homepage only (visible when page layout is "home")

Context Variables:

  • Block content: title, value, subtitle, subvalue, featured_image_url

  • Products: products array (slider enabled products only, sorted by sort order; only competitions that have reached their start date)

  • Settings: settings.primary_color, settings.background, settings.button_text_color, settings.site_name, settings.currency_icon

Product fields: id, title, subtitle, slug, url, image_url, slider_image_url, portrait_image_url, featured_video_url, video_embed_url, video_embed_type, video_embed_mime_type, video_embed_orientation, price, price_raw, price_display, original_price, original_price_raw, is_on_sale, is_free, has_question, question, cash_alt, cash_alt_raw, draw_date, end_date, start_date, start_date_raw, start_date_seconds, has_started, draw_date_raw, end_date_raw, draw_date_seconds, end_date_seconds, max_tickets, sold_tickets, tickets_remaining, percent_sold, max_per_user, has_ended, is_sold_out, is_active, is_featured, auto_draw, leaderboard_enabled, instant_wins, instant_wins_remaining, game_type, winner_qty, simple_max_ticket, category, categories, description, gallery

SplideJS (IMPORTANT): Use Alpine.js for initialization - NOT data-splide attribute. Pattern:

Common options: type (loop/slide/fade), perPage, gap, autoplay, interval, pauseOnHover, arrows, pagination, breakpoints, speed, easing.

Dynamic Alpine Components:

  • raffleCountdown(seconds) - Live countdown. Props: time.days/hours/minutes/seconds, hasEnded, pad()

  • raffleProgress(percent) - Progress bar. Props: percent, width

Best Practices:

  • Always use settings variables for colours via CSS custom properties (e.g., --slider-primary: {{ settings.primary_color|default('#4ade80') }})

  • All templates MUST be mobile responsive with @media queries

  • Reduce padding on mobile (24px vertical, 12px horizontal) to maximize above-the-fold content

  • Reduce font sizes, image heights, and element padding on mobile for better space efficiency

  • Use loading="lazy" on images

  • Include hover states and transitions for interactive elements

  • Examples are used only for context, always follow the customers design directives.


See also: Settings Variables for the global settings available in all Twig templates, and How the Slider Chooses Competitions for how products are picked for the slider.

Last updated