Questions tagged [phtml]

Denotes questions related to template `.phtml` files

Filter by
Sorted by
Tagged with
55
votes
6answers
44k 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"&...
13
votes
3answers
19k 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 = $...
8
votes
4answers
20k 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.
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.
1
vote
2answers
320 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 ...
19
votes
4answers
37k 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 = $...
7
votes
3answers
17k 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\...
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
18k 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/...
16
votes
2answers
53k 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
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
86 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 <...
36
votes
6answers
61k 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 ...
22
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(); } ....
17
votes
6answers
32k 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
16k 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 ...
10
votes
4answers
18k 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->...
1
vote
1answer
782 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 ...
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 = $...
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
1answer
2k 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/...
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 ...
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
7k 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
9k 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
556 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 ...
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="...
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
2
votes
2answers
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
773 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
297 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....
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
373 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
1answer
936 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/...
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?
1
vote
1answer
307 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
0answers
54 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
151 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
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
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 ...
0
votes
0answers
11 views

How to show the static block only for logged in customers globally?

I have created static block in admin panel and want to show that block only for logged in customers. I have tried it via creating the module and in template file I have written a condition to show the ...
0
votes
1answer
1k views

calling a phtml file in static block and vice versa is not working

in cart page , we implemented a feature of finding shipping charges using this file : app/design/frontend/default/theme/template/checkout/cart/shipping.phtml I need the same feature in cart page.... ...
0
votes
1answer
56 views

Magento 2: How to insert a custom JS file in the header of custom theme. This custom JS file is placed in pub/media/pmm-custom directory?

I'm looking for a way to add a custom js file in the header.phtml file. I don't place custom JS file under theme_directory for a obvious reason. Could anyone please tell me how to override header ...
0
votes
1answer
34 views

Magento2.3: Cannot open links in Myaccount dashboard

I'm implementing my own design to My Account dashboard. Unfortunately, I'm not able to open the Address Book and Address Information. When am clicking those links, I'm getting the below attached error....
0
votes
1answer
5k views

Calling a custom phtml file in another phtml file, cms block, cms page, and XML layout in Magento 2

There may be situation when you are developing a Project, you may need to call a custome phtml file in another phtml file cms page cms block (static block) xml layout How to do it ?