Skip to content

Header layout

Every theme lets you choose where the header shows the category menu and the product search. Each theme comes with the layout it was designed with, and you can change it when you install the theme or later.

OptionValues
--menuinline: in the logo row, between the logo and the account links
below: on a row of its own under the logo row, under a hairline
bar: in a full-width band under the logo row
--searchnone: no search in the header
inline: in the logo row
below: on a row of its own under the logo row
icon: a magnifier in the logo row that opens the search in a dropdown

On mobile, the menu always opens in an off-canvas panel and the search takes a row of its own under the logo (with icon, the magnifier stays in the logo row and its dropdown spans the screen width).

ThemeMenuSearch
Culture, Depotbelownone
Torquebelowinline
Drivebarinline
Every other themeinlinenone

Drive only supports the bar menu: its aisles bar has a title and a promotion link of its own.

The header of the Canvas theme on desktop (1440 px), light scheme.

Menu placement

--menu=inline (Canvas default):

Canvas header with the category menu in the logo row, between the logo and the account links

--menu=below:

Canvas header with the category menu on a row of its own under the logo row, under a hairline

--menu=bar:

Canvas header with the category menu in a full-width band under the logo row

Search placement

--search=inline:

Canvas header with the search field in the logo row, next to the category menu

--menu=bar --search=below:

Canvas header with the search on a row of its own under the logo row, above the full-width menu band

--search=icon, dropdown open:

Canvas header with a magnifier in the logo row and the search dropdown open under it

--search=icon on mobile (390 px), dropdown open--menu=bar --search=inline, dark scheme
Canvas header on mobile with the search dropdown spanning the screen widthCanvas header in the dark scheme with the search in the logo row and the menu in a full-width band

Themes with their own search or layout

Drive with --search=icon: its search by aisle, in the dropdown.

Drive header with the search by aisle open in the dropdown of the magnifier

Depot with its default layout (--menu=below), then with --menu=inline --search=icon:

Depot header with the category menu on a row of its own under the logo row

Depot header with the category menu in the logo row and a search magnifier

Terminal window
castor sylius:theme:setup canvas --menu=below --search=inline

To change the layout of the installed theme without reinstalling it (no asset build, only a cache clear):

Terminal window
castor sylius:theme:header # shows the current layout
castor sylius:theme:header --menu=bar --search=below
castor sylius:theme:header --search=none --theme=cellar # a theme installed with --target=theme-bundle

With the theme-bundle target, each theme keeps its own layout, so each channel gets the layout of its theme.

The inline search next to an inline menu suits short menus: with many categories, the menu links wrap on two lines. Prefer below or bar for the menu then.

The layout is shared by every theme (src/Themes/header_layout/, installed by OpenColibri\Starter\Themes\HeaderLayout, like the color schemes):

  • the options are Twig hook configuration, generated in config/sylius/twig_hooks/shop/base/header_layout.php (in config/sylius/twig_hooks/themes/<theme>/ with the theme-bundle target, prefixed with the theme): do not edit it, use castor sylius:theme:header;
  • the themes_header_layout hookable adds the header-menu--<menu> and header-search--<search> classes to the page wrapper (sylius_shop.base#body_classes);
  • _header-layout.scss, imported at the root of each theme app.scss, lays the header row out from these classes, once for every theme. The menu column of each theme carries the header-category-nav class;
  • the themes_header_search hookable (sylius_shop.base.header.content, priority 240, disabled with none) renders shop/shared/layout/header_layout/search.html.twig: a header-search column, or with icon a Bootstrap dropdown (like the color scheme switcher) whose field gets the focus when it opens. Both hold search_form.html.twig, a search on the whole catalogue through the product listing of the channel menu taxon, which includes its descendants.

A theme styles the menu and the search like the rest of its header, and only adds rules for a placement it wants to look different (.header-menu--below .<theme>-category-nav…). To replace the search form, a theme ships templates/shop/shared/layout/header_layout/search_form.html.twig (it gets an id for the field), which then works in every placement: Torque reuses the search form of its hero, Drive its search by aisle.