Extend Storefront¶
Built-in menus¶
With the ibexa\storefront package come the following built-in menus:
| Item | Value | Description |
|---|---|---|
| Breadcrumbs | - | Renders breadcrumbs for content tree root, Taxonomy Entry, product, user settings, and user settings group |
| Taxonomy | - | It can render a menu for product categories or tags |
| Currency | currency_menu |
Renders a menu to change the active currency |
| Language | language_menu |
Renders a menu to change the active language |
| Region | region_menu |
Renders a menu to change the active region |
Usage example:
1 2 3 | |
Breadcrumbs menu¶
To modify the items in the menu, you need to use an event subscriber.
This subscriber replaces the URI under the Home link.
Create an event subscriber in src/EventSubscriber/BreadcrumbsMenuSubscriber.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Next, create the templates/themes/storefront/storefront/knp_menu/breadcrumbs.html.twig template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Next, extend the templates/themes/storefront/storefront/product.html.twig template to include the breadcrumbs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Taxonomy menu¶
You can build a taxonomy menu for, for example, product categories or tags.
See the usage example:
1 2 3 4 5 6 7 8 9 10 | |
It takes the following parameters:
| Name | Type | Default |
|---|---|---|
parent |
\Ibexa\Contracts\Taxonomy\Value\TaxonomyEntry |
The root entry of the specified taxonomy. |
depth |
int |
Default: 1 |
taxonomy_name |
string |
product_categories |
Create menu items¶
\Ibexa\Contracts\Storefront\Menu\ItemFactoryInterface provides convenient methods to build menu item based on repository objects, including:
- Content
- Content ID
- Location
- Location ID
- Taxonomy Entry
- Product
Generate custom product preview path¶
By default, the ProductRenderController controller passes only the product object for rendering.
You can modify the controller file to make it pass parameters to the path Twig helper function, which is used by the product_card.html.twig and product_card.html.twig templates to generate the user path.
After you modify the controller, it can also pass the following parameters:
route- the route, under which product preview is available.parameters- parameters to be used, for example, to render the view.is_relative- Boolean that decides whether the URL is relative or absolute.
Define your own logic in a custom controller.
Refer to the code snippet below and create your own file, for example, CustomProductRenderController.php:
1 2 3 4 5 6 7 8 9 | |