Edit in GitHubLog an issue

Template customization walkthrough

This topic walks you through how to customize a template.

Prerequisites

Set your application to the developer mode. The application mode influences the way static files are cached by the application. The recommendations about theme development we provide in this chapter are developer/default-mode specific.

Template customization walkthrough

To customize a template:

  1. Locate the template which is associated with the page/block you want to change using template hints.

  2. Copy the template to your theme folder according to the template storing convention.

  3. Make the required changes.

To add a new template in a theme:

  1. Add a template in your theme directory according to the template storing convention.

  2. Assign your template to a block in the corresponding layout file.

Walkthrough illustration: adding a message to the customer review form

A small customization to illustrate the walkthrough: in their Orange theme, the ExampleCorp company wants to add a short text to the product review form to encourage customers to write reviews.

The following image illustrates how the default review form looks like:

Default review form

To add the text, ExampleCorp needs to override the default review form template in the Orange theme.

First, they copy the form.phtml template from <Magento_Review_module_dir>/view/frontend/templates to the corresponding subdirectory in the Orange theme directory: app/design/frontend/ExampleCorp/orange/Magento_Review/templates.

In the theme form.phtml file they add the HTML snippet with the message before the <form>:

HTML snippet to add

Here's how the form will look when the Orange theme is applied in a store:

Review form with the new message added

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.