Questions tagged [template]

The folder that contains all the `phtml` files used to display at frontend or backend.

Filter by
Sorted by
Tagged with
27
votes
4answers
18k views

Theming for Magento 2 - Starting from scratch

Some of you probably read that topic regarding theming from scratch for Magento 1: Theming - starting from scratch I was wondering, what would be the best practice to develop a theme from scratch for ...
6
votes
3answers
4k views

Different Footer per Page

I have a request from client where he wants to put google analytics code on different pages in Magento under footer. I see that footer is generic, so is there a way to place a different code under ...
13
votes
3answers
16k views

Magento 2 Get order total on success page?

I'm trying to get the order total on the success page on magento 2 , I have added this code <?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); $totall = $...
14
votes
2answers
32k views

Adding custom layouts for CMS and Category use with custom module trouble

I have a category in my store that requires a totally different layout to the standard Magento layouts. So I created a new copy of the 1column.phtml and renamed it and made one small change to test. ...
7
votes
2answers
6k views

How to add Qty in add to cart form on Product Listings Page in Magento 2

How can you add a Qty filed to the the add to cart form on the category listings page. With the Luma theme the user only has the option to add one product to cart at a time from the product listings ...
3
votes
3answers
9k views

How to customize the customer registration form? [duplicate]

I want to modify the customer registration form in Magento 1.9. There are two forms both under templates 1. Customer and 2. Persistent. So which template should be modified ? Because I have made ...
27
votes
4answers
27k views

How to escape output data?

Is there a built-in Magento helper to escape outputted template data to prevent XSS? Or should I just use the PHP htmlspecialchars or htmlentities functions?
14
votes
14answers
14k views

Magento2 : Change order of Tabs on Product Page

I'm trying to change the order of the tabs on the product page in Magento 2. Default is Details|More Information|Reviews. I tried: Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml <...
10
votes
2answers
32k views

Creating a custom homepage template in Magento2

As all you know that magento2 have some layout template like 1column , 2 columns-left , 2 columns-right , 3 columns and I want to create custom homepage layout template in Magento2 for that I follow ...
5
votes
2answers
14k views

Magento 2 - Custom Page Layout

I wish to add a custom home page layout in Magento 2. In Magento 1, it's very simple, i create my module : <?xml version="1.0"?> <config> <modules> <Vendor_Custom>...
5
votes
3answers
11k views

How to override an admin theme template?

I would like to override app/design/adminhtml/default/default/template/page.phtml i'm currently using an extension that overrides app/design/adminhtml/default/default/template/page/header.phtml with ...
29
votes
2answers
7k views

Magento 2: template security: which method to use?

I'm aware Magento 2 has several methods available to secure the template: $block->escapeHtml() $block->escapeQuote() $block->escapeUrl() $block->escapeXssInUrl() But I'm wondering when ...
32
votes
3answers
30k views

Conditionally show/hide blocks in layout XML

How to conditionally add a block (depending on the configuration in the admin panel) in Magento's layout XML? We can check if config is true on actions. In the example below, if sample/config/...
36
votes
10answers
28k views

Where is Template Path Hints in Magento 2?

Just started playing about with Magento 2. Can anyone tell me where I can find the "Template Path Hints" option that used to be in System > Configuration > Developer > Debug?
23
votes
13answers
30k views

Getting full image URL of product in template

I'm trying to create a static block for showing dynamic products. This is code that is supposed to get every child category and print the image for each product in each category. <?php $...
5
votes
1answer
5k views

how to override template files for magento2 extension

In magento2 to override template files here, but for magento2 extension we have to follow here. So how to override template files in magento2 extension with out considering theme inheritance. I want ...
16
votes
4answers
5k views

Magento2 localisation Javascript

A similar question was already asked here: Magento 2 javascript text translations, but Magento updated this translation technique in the beta version. How can I add or update translations used by ...
21
votes
3answers
13k views

Magento 2 - How to get the extension's configuration values in the phtml files?

I'm working with Magento 2 - beta. But cannot find how to get the configuration values in the phtml files. eg: I want to get my custom modules configuration values in Magento_Catalog/templates/...
20
votes
4answers
14k views

How to override a HTML file using a custom module?

I'm developing a custom module for payment method in Magento 2. Currently, I'm using cc-form.html from vendor directory and module working fine. See below path: vendor/magento/module-payment/view/...
27
votes
2answers
3k views

Magento 2 Templates: Use `$block` or `$this`?

In Magento 2, the $this variable no longer refereces to a template's block object. It refers to a template class Magento\Framework\View\TemplateEngine\Php However, this template class has a ...
12
votes
4answers
16k views

Magento 2 - Override base view file

I'm currently developing a Magento 2.0 theme. I'm trying to change the behaviour of the Tax class on the frontend. The file I need to change is located in app/Code/Magento/Tax/view/base/templates/...
17
votes
6answers
10k views

How to get store phone number in magento 2

I want to display phone number saved in magento admin in frontend in magento 2. Like in magento 1.9 its like $storePhone = Mage::getStoreConfig('general/store_information/phone');
10
votes
1answer
5k views

Magento 2 : How to add placeholder text to street fields in checkout?

In back-end I've set the street address to have 3 lines. I'd like to put a different placeholder in each field: Street Building / Apartment Area This way user can enter data in a more structured ...
8
votes
4answers
6k views

How to know which translation csv file(s) are used in the current phtml file

Is there a method to know which translation CSV file(s) are used in the current phtml template file?
6
votes
2answers
14k views

Magento 2: How to call custom phtml file in another phtml file?

I'm trying to output custom phtml content of Lapisbard_General::customer_account.phtml in Magento_directory::currency.phtml If I'm using below code, it works fine. echo $this->getLayout()->...
2
votes
1answer
2k views

How to use setTemplate() in Custom modules _construct() magento2

How to achieve the setTemplate() in the custom modules constructor? protected function _construct() { $this->setTemplate('Myfolder/filter.phtml'); } protected function _toHtml() { return ...
2
votes
1answer
2k views

Add placeholder and remove all labels in Magento 2 Checkout

Searched a lot but didn't found anything removing the Lables like "First Name, Last Name, City, Address, Email, Phone etc" Add Placeholders in all "shipping fields" and "sign In" places. After ...
1
vote
1answer
6k views

How to get global messages in compare products page, getMessagesBlock is empty

I'm trying to get global messages in compare products page, but none of the messages get rendered, instead all of them appear in any subsequent page I'm going, after producing messages with for ...
32
votes
3answers
44k views

magento 2 how to call any block function in phtml

How can I call any block function in any phtml? For example if I want to call my custom block function in product list.phtml?
10
votes
2answers
18k views

How to overwrite core template files from a custom module?

I want to overwrite two files. Namely the view.phtml and print.phtml of sales orders. (path: app/design/frontend/base/default/template/sales/order/) I am creating a module in which I want to create a ...
13
votes
2answers
1k views

Magento 2: What's an `<each/>` Tag?

As near as I can tell, when you view a Grid in Magento's backend, the following "loaded over XHR" KnockoutJS template is what starts rendering things File: vendor/magento//module-ui/view/base/web/...
9
votes
2answers
2k views

Magento 2: proper use of helpers

I'm starting to see more and more people declaring helpers classes in order to be able to use the following in the template files: $this->helper('Path/To/Helper/Class')->customMethod(); This ...
6
votes
4answers
38k views

Magento 2 Get product collection in a custom template block

I have defined a featured product template in a cms static page as below: {{block class="Magento\Catalog\Block\Product\ListProduct" template="Magento_Catalog::product/featured.phtml"}} Now I want to ...
6
votes
3answers
3k views

Adding button in Magento 2

I'm trying to add button in customer address form. But I don't know how to do it from customer_form.xml file. If any one knows please suggest me. I have registered button control on ui_definition.xsd ...
12
votes
1answer
14k views

How rendering of price.phtml in catalog product listing page is happening?

Catalog Product listing page's template file is list.phtml. Where the rendering of all the products in category happens using foreach loop. I am confused about the rendering of the price.phtml. ...
9
votes
3answers
8k views

How to overwrite a template via module in Magento2

I am creating a module and want to overwrite the template app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml. Is this possible in a module (not a theme) ...
9
votes
4answers
6k views

Magento 2: How to change template of a block without “name”

I want to change to override a block's template with my custom template. But it does not have a "name", it only has a "as". The one I want to override is: <block class="Magento\Sales\Block\...
4
votes
1answer
2k views

Magento 2: How to move additional product attributes to Details tab?

In Blank theme, attributes other than description display under More information tab. In my theme, I want to move attributes from More Information to Details tab. Example: Details tab contains ...
3
votes
3answers
5k views

Magento 2 Create custom 404 page for not-found products

In Magento 2 I am looking to create a module that adds a custom 404 page specifically for not-found products in the catalog, however keep the default 404 page for all other pages. My initial thoughts ...
3
votes
1answer
4k views

How to overwrite lib template file - Magento 2

How can the HTML files from the library be overwritten? I need to overwrite this template: lib/web/mage/gallery/gallery.html I have tried placing the file in my own theme in the below locations, I'...
8
votes
2answers
1k views

Using different escaping methods

I noticed class vendor/magento/framework/Escaper.php which contains a few useful security methods used inside (mainly) templates. Some of them are quite common (escapeHtml()), but some of them are ...
6
votes
3answers
19k views

Where Do I Put a Template To Add Using {{block type=“core/template” template=“template.phtml”}}

I am new to Magento and so sorry for the noddy question. I am trying to add php to a CMS page and the way to do this appears to be to put the php (including Mage calls) to a phtml template and then ...
5
votes
1answer
924 views

Difference Between $block and $this magento 2

I have block Class Name NameSpace1\Test\Block\Test with method getTest() namespace NameSpace1\Test\Block; class Test extends \Magento\Framework\View\Element\Template { public function getTest(){ ...
4
votes
1answer
6k views

Magento 2: how to declare a custom email template for your module

In Magento 1, you could declare email templates directly in the config.xml like this: <template> <email> <custom_email_template translate="label" module="modulename"> ...
3
votes
2answers
933 views

Customer VS persistent/customer templates

I want to know exactly what is the difference between templates located in customer and persistent/customer and why Magento created the two ? Exemple : app/design/frontend/{package}/{theme}/...
2
votes
1answer
1k views

Access Message Manager from phtml

vendor/magento/module-contact/Controller/Index/Post.php set in session messages like $this->messageManager->addSuccess( __('Thanks for contacting us with your comments and questions. We\'...
1
vote
1answer
3k views

How to retrieve product add to cart url in phtml file

I'm looking to add 5 products add to cart buttons to a CMS page in Magento 2, the code example I found online is: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $listBlock = $...
1
vote
2answers
843 views

Override HTML Template from custom module not working

I am trying to override HTML template in my custom module. I am working on Magento ver 2.2.2 Vendor/Moule/view/frontend, I have created a requirejs-config.js file: var config = { map: { ...
13
votes
3answers
16k views

How to get store name in template?

How is it possible to output the current store name in a Magento 2 custom template with a custom block?
5
votes
1answer
23k views

Get category image to a page template

I have created a new page template here: /template/page/category.phtml and copied inside the content of 1column.phtml. What I want to accomplish is to get the category data variable in this new ...