We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [template]

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

Filter by
Sorted by
Tagged with
66
votes
2answers
11k views

Magento 2 @escapeNotVerified

I see a lot of occurences of this comment /* @escapeNotVerified */ in the template files for Magento2. Does it have a special meaning? Is there any use for this? Examples: https://github.com/...
36
votes
8answers
27k 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?
35
votes
5answers
9k views

Are Symlinks on templates a security problem, and if yes, why?

Magento recommends to not use templates via symlinks: Advanced > Developer > Template Settings > Allow Symlinks Warning! Enabling this feature is not recommended on production ...
32
votes
3answers
43k 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?
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/...
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 ...
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 ...
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?
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 ...
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 $...
21
votes
3answers
12k 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
13k 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/...
19
votes
2answers
6k views

Usage of page factory class in magento2

What is the purpose of rendering the custom module page in Magento2 using the result factory \Magento\Framework\View\Result\PageFactory class injected in the constructor and making the page to display ...
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');
16
votes
5answers
28k views

Why does my translate.csv and the translation files not work?

I'm trying out a new theme and it seems to not get the translations properly. If I search for the English phrase in my files, I can find: "You have no items to compare.","Sie haben keine Artikel ...
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 ...
15
votes
5answers
11k views

Magento 2: How to set custom template for core block

I'm trying to override the register.phtml in my module, but it seems there are some config problem that make Magento unable to use my custom template to override the one in core module. I've checked ...
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 <...
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. ...
14
votes
4answers
2k views

Is it good to instantiate a getModel class on phtml templates?

This is a question regarding a good programming practices in Magento. I need to show (in the category product list) the product with its related products in thumbnails. So I edited mypackage/mytheme/...
14
votes
1answer
9k views

Customization of total order and additional infos

When want to have the following style of totals on checkout/cart: Discount Subtotal Shipping fee OR Info Text: "excl. shipping" Additional text: "free shipping from 30EUR" (display always) ...
14
votes
2answers
319 views

How to keep .phtml files lean and clean?

As its file extension suggests a .phtml file allows PHP code to be mixed with HTML. However, the fact that you can should not be seen as a license to go wild. Why do we still see so many .phtml ...
13
votes
5answers
25k views

Magento2: Get Media URL In Template File (Without direct Calling Object Manager )

How to Get Media URL in Template file ? All the solution i found is calling Object Manager directly. My another concern, Can you ever call object manager directly as best practice ? (because in most ...
13
votes
6answers
13k views

How to remove Company field from checkout process in Magento 2?

How to remove Company field from checkout process in Magento 2? I've been looking for the template but have not found it. Update: Is there any way to remove this field via layout or template?
13
votes
3answers
15k 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 = $...
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?
13
votes
2answers
11k views

Template path not showing

For some reason the template path hints are not displayed. I went to the admin panel and turned them off and on again, then cleared the cache. But they are still not displaying. How can I debug/...
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/...
12
votes
6answers
14k views

Load js in footer in Magento

<reference name="footer"> <action method="addItem"> <type>skin_js</type> <file>js/fabric/tool/controller_tool.js</file> </action> </...
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. ...
12
votes
1answer
3k views

Messages block not using theme template

I am trying to change the phtml file for the messages block. I found in the base theme template/core/messages.phtml and copied that over to my theme and made the changes. My changes didn't show so I ...
11
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/...
11
votes
1answer
12k views

What is the difference between getChildHtml and getBlockHtml

Synopsis What is the difference between getChildHtml and getBlockHtml? How can I get the cms/block title in the template? I have essentially replaced the footer with my own footer and set my own <...
11
votes
1answer
1k views

When and how are phtml templates generated in view_preprocessed?

I see lots of phtml files generated in var/view_preprocessed/html, from core modules as well as from custom modules. It looks like these are all used templates with stripped whitespace. Alan Kent ...
10
votes
2answers
31k 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 ...
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 ...
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 ...
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 ...
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\...
9
votes
4answers
4k views

Magento 2 - How to apply Slick Slider to Recently Viewed Widget

I have created a code but slider is not showing up in recently viewed products. Here is my code - I have downloaded slick js and css from the following link http://kenwheeler.github.io/slick/ Then ...
8
votes
1answer
7k views

Cannot get custom frontend ajax layout to load

I always have challenges identifying the proper handles for everything, so please bear with me here. I've scoured Google, SE, and tried myriad variations, with no luck. (And yes, I've used ...
8
votes
2answers
15k views

Custom template for static blocks in CMS page?

I searched the web and could not find how to do this. I want to add a static block that I have created in admin before to a cms-page. This works using either of this lines: {{block type="cms/block" ...
8
votes
2answers
7k views

Can you load a widget instance from a template?

I'd like to create 'widgets' in certain areas on my site, that can have certain parameters configurable by a non-technical Magento store admin. Widgets, by all descriptions sound like a nice way of ...
8
votes
2answers
4k views

Magento 2 knockout js in checkout page

I want to customize checkout page but i am confused about calling template with knockout js. In Magento/Checkout/view/frontend/templates/onepage.phtml there is a script like this: <!-- ko template:...
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 ...
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?
8
votes
1answer
3k views

Magento 2 custom template and ReactJS

Does anyone have experience using ReactJS when making a custom Magento template? Or does anyone know if it is viable? I would like to leverage ReactJS to make a single-page website.
7
votes
2answers
996 views

Applied PATCH_SUPEE-6285 - Do I need to do anything else?

After being prompted to install the new patch I went ahead and did so straight away. But now I've gone back and looked at the .sh file I noticed there is changes being made to template files. I had ...
7
votes
1answer
8k views

Difference between $this->helper and Mage::helper

Is the following codes in the phtml $this->helper('catalog/category') and Mage::helper('catalog/category') returns the same object? What is the meaning of using $this->helper() and Mage::...