How to override .phtml file in module?
-
29-03-2021 - |
Question
I am trying to change sign in or create an account message which is called by block named product.review.form
in catalog_product_view.xml.
/vendor/magento/module-review/view/frontend/layout/catalog_product_view.xml
The template used is form.phtml which is set in Magento\Review\Block\Form.php
I want to override this part of code in
/vendor/magento/module-review/view/frontend/templates/form.phtml
<?php else : ?>
<div class="message info notlogged" id="review-form">
<div>
<?= $block->escapeHtml(__('Only registered users can write reviews. Please <a href="%2">Sign in</a> or <a href="%1">create an account</a>', $block->getLoginLink(), $block->getRegisterUrl()), ['a']) ?>
</div>
</div>
<?php endif ?>
Question : How can i override the sentence in that particular <div>
?
Note : I tried to use plug-in but _construct() is protected and using preference is not suitable for my requirement.
Solution
It can be override by adding the content / message in the en_US.csv file in the your custom theme.
For reference check the row 120 in sitename/vendor/magento/module-review/i18n/en_US.csv
.