Salla Docs
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Salla - Opensource
Salla - Developers Community
  1. Layouts
  • Getting Started
    • Create a theme
    • Develop a theme
    • Setup a theme
    • Publish a theme
  • Requirements & Review
    • Overview
    • Main Requirements
    • Review Process
      • UI / UX Review
      • Technical Review
      • Metadata Review
      • Pre-Launch Review
  • Files and Folders Structure
    • Directory structure
    • Twilight.json
  • Twig Template Engine
    • Basic syntax
    • Twilight flavoured twig
  • Theme Architecture
    • Layouts
      • Overview
      • Master Layout
      • Global Variables
      • CSS Variables
      • Salla Icons
      • Custom Fonts
      • Hooks
      • Localizations
    • Pages
      • Overview
      • Home Page
      • Product Pages
        • Products listing
        • Single product
      • Customer Pages
        • Profile
        • Orders list
        • Order details
        • Wishlist
        • Notifications
      • Blog Pages
        • Blog listing
        • Single blog
      • Brand Pages
        • Brands listing
        • Single brand
      • Common Pages
        • Cart
        • Loyalty
        • Thank you
        • Single page
        • Landing Page
    • Componenets
      • Overview
      • Home Components
        • Youtube
        • Fixed banner
        • Testimonials
        • Parallax background
        • Photos slider
        • Store features
        • Square photos
        • Fixed products
        • Products slider
        • Featured products - Style 1
        • Featured Products - Style 2
        • Featured Products - Style 3
        • Brands
        • Enhanced Square Banners
        • Main Links
        • Enhanced Slider
        • Slider Products with Headers
        • Latest Products
        • Vertical Menu with Slider
      • Product Components
        • Essentials
        • Options
      • Common Components
        • Header Components
        • Footer Components
        • Comments component
  • Change Log
  1. Layouts

Overview

Layouts are considered the foundation for Salla theme, through which all of the theme pages will share the same layout. When building a Salla theme, you will need to start by planing for your layouts, so then you can use them to unify your pages' look-and-feel.

📙 What you'll learn about#

Locate Layout files .
Master layout hooks.
Using layouts.
Embed theme pages within the layout.
Build a new layout.

Locate Layout files#

According to the Twilight directory structure, all of the layouts should be stored in the src/views/layouts/ folder.

Master layout hooks#

Most of the theme hooks are used within the master layout. This is due to the fact that this layout, which can be overwritten by the developer, is used across all of the website pages. It means that all of the hooks' contents will be injected into all of the website pages.

Using layouts#

As we saw in the Twig basic syntax, template inheritance is one of twigs perks; it allows you to set a base code that contains all of the elements for your website and define blocks that can override from child templates.
Inheritance is the main concept of building layouts. The developer starts by creating an HTML page with the overall skeleton of the theme pages, with creating blocks inside it for future content. These future contents will be filled by the page that will inherit this layout page.
Information
A default layout is created at src/views/layouts/master.twig.

Embed theme pages within the layout.#

In order to embed the theme pages within the layout page, first we need to extend, inherit, the layout page. In the following example, we have a mylayout.twig file where we define three blocks: head, title and footer.
To embed the theme pages within this layout, we start by extending them. Then we will enject the content into the defined three blocks: head, title and footer.

Build a new layout#

Building layouts is easy with Twilight; we simply need to create any new layout file inside the folder src\views\layouts\. This step will make the layout available throughout the theme pages.
Note that all of the new files are nothing but *.twig files.
The main two steps for building layouts are:
Create an HTML file, with the extension *.twig, that contains the main skeleton of your theme with creating blocks inside it for future contents.
Extend this layout page inside your theme's pages, and enject the content within the predefined blocks.
Modified at 2025-03-04 12:54:02
Previous
Layouts
Next
Master Layout