Questions tagged [phtml]

Denotes questions related to template `.phtml` files

Filter by
Sorted by
Tagged with
58
votes
6answers
48k views

Magento 2: Changing a Block's Template

In Magento 1, as a module developer it's possible to change a block's template using layout XML code something like this <reference name="block_to_change"> <action method="setTemplate"&...
14
votes
3answers
21k 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 = $...
6
votes
1answer
4k views

How to override adminhtml phtml in magento 2?

Does anyone know how to override the below template? vendor\magento\module-backend\view\adminhtml\templates\media\uploader.phtml.
8
votes
4answers
21k views

How to get the Description of a Magento\Catalog\Model\Product?

I'm in Magento2 and the getDescription(); does not work. I'm in the file Magento_Catalog/templates/product/list.phtml if that's relevant.
19
votes
4answers
40k views

How do I get the current product?

I'm trying to retrieve the current product's attributes in a block in Magento 2. I can get a product, like ID 1: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $...
16
votes
2answers
54k views

call static block in view.phtml insted of phtml file

we are displaying text field in view page to check COD availability. view.phtml echo $this->getLayout()->createBlock('core/template')->setTemplate('checkdelivery/checkdelivery.phtml')->...
7
votes
3answers
18k views

How to load a phtml file only for homepage? (Magento 2)

I am trying to load a phtml file like this: File /app/design/frontend/name/themename/Magento_Theme/layout/default.xml <referenceContainer name="page.top"> <block class="Magento\...
1
vote
2answers
365 views

Magento 2: jQuery Datatables Button Extentions Not Working

============================UPDATED 1.1============================ I'm new to Magento 2.3, I'm trying to apply jQuery DataTable(DONE), after than, I want to add it's Button Extension, for that i ...
38
votes
6answers
65k views

Add a static image on PHTML page and CMS Blocks : Magento2

How I can Add a static image on PHTML page and CMS Blocks into Magento2? in Magento 1.x it was possible using $this->getSkinUrl('images/xyz.jpg') I am trying following method into Magento2 In ...
29
votes
2answers
4k 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 ...
14
votes
4answers
19k 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
4answers
19k views

Magento 2 Get Cart Quote Total in minicart.phtml

I'm trying to get the cart quote total in minicart.phtml, but I'm having no luck. I'm injecting Magento\Checkout\Model\Cart. Here's my code: $this->cart = $cart; $cartQuote= $this->cart->...
7
votes
1answer
4k views

Add Images in Magento Theme template file

I want to add image like footer.png in app/design/frontend/vendorname/themename/Magento_Theme/templates/html/footer.phtml Here I am adding image using <img src='<?php echo $this->...
0
votes
1answer
218 views

Magento 2: Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: Perfectmirrors\PmmLayout\Block\Head

I am really not sure how to create the block class Pmm\PmmLayout\Block\Head , function of which $block->getAllPagesJSContent() should be called inside my phtml file pmm_head.phtml <...
23
votes
5answers
32k views

Send data from the controller to phtml

I have this controller: ... public function insertAction() { $something = 'testcase'; $this->loadLayout(); $this->_title($this->__("the title")); $this->renderLayout(); } ....
18
votes
7answers
35k views

How to call helper method in .phtml file

Trying to develop something in magento 2. But, I didn't find how to call a Helper method in template(.phtml) file. I want a replacement of below code: $this->helper('modulename/helpername')->...
12
votes
2answers
6k views

Magento 2: Passing Variables from Controller Action to “View”

In Magento 1, if you want to pass data from your Controller action to the "View" (i.e. a block in your layout, you can) Add a value/object to the global registry via Mage::register Directly fetch a ...
24
votes
3answers
17k views

magento 2: I want display a image in the module template phtml file

I want to display an image in the module template file. When somebody installs my module, he can see that image. Can I store my images inside my module directory or not?
5
votes
2answers
12k views

Override Magento 2 phtml Files?

Is it possible to override Magento 2 Luma phtml Files? I've created a new theme based on Luma which is working perfectly but I can't find any phtml files anywhere. I've also noticed my app/code ...
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
1answer
804 views

Custom css for custom block/phtml.

Where should I put the custom .css file for my custom block/phtml. When I want to customize the display of my block then I have to create a custom .css for that. But where do I have to put that .css ...
4
votes
2answers
3k views

Customer create account template comes from path “persistent/”. Why is that?

In my localhost/Magento, my theme path is base/default. I try to edit my PHTML file for Create Account. Basicly this file came from app/design/frontend/base/default/template/customer/form/...
3
votes
2answers
2k views

Magento 2 create custom block and phtml in Magento_Customer module

I want to create a new custom Block and Block phtml file same as the Customer Index Block for use to the customer, when customer login the customer just click on the left navigation link and access ...
1
vote
2answers
3k views

Show PHTML-file in CMS page is not working

I'm trying to call a phtml file in a CMS Page and I know that there are several question for exactly that question already on Stackexchange. The problem is: its not working. I can't get it to running ...
1
vote
1answer
3k views

Overriding template not working in Magento 2

I have following code etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/...
14
votes
1answer
24k views

Magento 2 Override default header template

I have created my own theme by extending the Magento/Blank theme. Now want to override the default header template files link.phtml, topmenu.phtml, header.phtml which is located at vendor/module-...
4
votes
1answer
8k views

How render product wishlist link functionality in custom template (phtml) in magento 2

How to display wishlist link (with functionality) in custom phtml file using template file in magento 2
5
votes
1answer
2k views

How to Override phtml file in Magento 2?

I am overwriting vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtl and I tried puting the overriden file in two locations but no chages occur First: app/code/<...
5
votes
3answers
10k views

How to call widget with products of specific category in “.phtml” file?

How can I call a widget that displays product from a specific category in a phtml file? Currently I can only display "all_products" in my phtml file like that: echo $this->getLayout()->...
2
votes
1answer
601 views

Call CMS Block with Category name as Identifier

The goal is to call a static cms block at the bottom of the category page, with block identifier == category name (so that I can make a block in the admin backend for every category). So I first ...
22
votes
4answers
38k views

How to get root directory path in a phtml magento 2?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $mediaPath = $fileSystem->...
9
votes
2answers
3k views

How can I display `₹` properly in invoice pdf without changing core files

₹ is properly displaying in front pages as well as product pages. But it is not displaying properly in pdf of invoice and shipment. How to change for proper displaying. I have tried changing in lib/...
6
votes
1answer
20k views

Magento include phtml file within another phtml file

I am making a custom home page for my magento website in a phtml file named home_banner.phtml, which in turn i have referenced in the CMS->Pages->Home Page content by the following code {{block type="...
3
votes
2answers
243 views

Magento 2 : How to override a custom module which install via composer?

I have installed one custom module using composer as usually that module was installed in vendor directory is there any way to override phtml file in the same module like name but on app/code module ...
2
votes
2answers
348 views

Extend tier_price.phtml in child theme of a custom theme Magento 2

From: /vendor/magento/module-configurable-product/view/base/templates/product/price/tier_price.phtml To: /app/design/frontend/Mgs/claue_child/Magento_Catalog/templates/product/tier_price....
2
votes
3answers
2k views

Why my overriding of the success.phtml is not working?

I have copied and pasted the file from vendor/magento/module-checkout/view/frontend/templates/success.phtml to app/design/frontend/THEME/THEMENAME/Magento_Checkout/templates/success.phtml ...
2
votes
1answer
871 views

how to call phtml file in email template in magento2

I need to pass the phtml file into email template. but I'm getting error like Error filtering template: Invalid template file: 'Vendor_Module::emailproducts.phtml' in module: '' block's name: '...
2
votes
2answers
2k views

How to override adminhtml phtml in Magento2?

How to override vendor/magento/module-shipping/view/adminhtml/templates/view/form.phtml file in magento2
1
vote
3answers
6k views

how to pass variable to phtml file in magento [duplicate]

form <input type="text" class="input-text required-entry validate-number form-control validate-zero-or-greater" id= "checkout-cart-credit-amount-textboxone" title="<?php echo $this->__('...
1
vote
1answer
466 views

How to add texts to payment step Onepage checkout page

Which file should i edit to add text underneath all the payment methods. ( I would like to add some return/refund policy). The URL is https://www.mywebsite.com/checkout/#payment
2
votes
2answers
2k views

How to get selected Allowed country list in Magento 2..?

I need to get the the Selected Allowed Countries in a phtml file.. How can i get that ?
2
votes
1answer
3k views

Magento 2 - Get Attribute Set by ID?

Is there a way from a phtml file to get the attributes of an attribute set given the set id?
2
votes
1answer
939 views

PHP, PHTML and other files get directories after updating via ./mage update-all

Since Magento 1.9.2.x (don't know which version exactly, but seems to be since 1.9.2.2) when updating via ./mage update-all some files turn into directories. This belongs to default files like ./app/...
1
vote
1answer
90 views

How to change the CSS only for Myaccount page title?

I want to change the CSS only for the title of My Account page. I have added my custom class into the file title.phtml at the path module-theme/view/frontend/templates/html But it affects all the ...
1
vote
1answer
3k views

Get Product Attribute In Custom PHTML block added to product page through xml

I've created a phtml file to display some custom product attributes on my product page however I am unsure how I can get the product attribute to display? I've tried <?php $objectManager = \...
1
vote
0answers
71 views

How to Add an icon next to Payment Method for Amazon Pay?

I have looked up a few similar question but can't figure how. It's the default amazon pay module that came with Magento 2 I'm editing this file /var/www/html/vendor/amzn/amazon-pay-module/view/...
1
vote
1answer
163 views

jQuery DataTables.js How to Apply It On Admin Grid

I'm very new to Magneto, I'm trying to add jQuery DataTables in Magento 2.3, in below image i get error in console: Here is my Code: Add file in /EC/Downloads/view/adminhtml/requirejs-config.js. ...
1
vote
2answers
902 views

Trying to override phtml template

I'm fairly new in Magento and trying to override a phtml file which is originally in app/design/frontend/rwd/default/template/catalog/product/view/type/availability/default.phtml with custom one ...
1
vote
1answer
350 views

Help with adding script codes between <head></head> in success.phtml

Hope someone can help me with this. It's very easy to do I bet, I'm just not used to magento yet. I'm adding Google Ads to my magento (1.9).. I need to add this script code: <!-- Event snippet ...
1
vote
3answers
3k views

Show content of phtml file on static block Magento 2

I have the code (details below) that basically generates links and images for a categories sub-categories. It is working in Magento 1.7 - we are moving to Magento 2 and I would like to get it working ...