how to call phtml inside phtml Planned maintenance scheduled April 23, 2019 at 00:00UTC...
What is the difference between globalisation and imperialism?
Why is it faster to reheat something than it is to cook it?
What initially awakened the Balrog?
Why do we need to use the builder design pattern when we can do the same thing with setters?
How to compare two different files line by line in unix?
How do living politicians protect their readily obtainable signatures from misuse?
What is this clumpy 20-30cm high yellow-flowered plant?
Generate an RGB colour grid
Is it fair for a professor to grade us on the possession of past papers?
What was the first language to use conditional keywords?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?
Should I follow up with an employee I believe overracted to a mistake I made?
How to write the following sign?
Chinese Seal on silk painting - what does it mean?
Find 108 by using 3,4,6
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
What is a fractional matching?
Putting class ranking in CV, but against dept guidelines
Maximum summed subsequences with non-adjacent items
Can the Great Weapon Master feat's damage bonus and accuracy penalty apply to attacks from the Spiritual Weapon spell?
What would you call this weird metallic apparatus that allows you to lift people?
Drawing without replacement: why is the order of draw irrelevant?
Is there hard evidence that the grant peer review system performs significantly better than random?
how to call phtml inside phtml
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 Templates: Use `$block` or `$this`?Magento custom block shows Fatal error: Call to a member function setTemplate() on a non-objectMagento 1.8 - Display block in email templateMagento 2: How to call custom phtml file in another phtml file?Magento 2 : Fatal error: Uncaught Error: Call to a member function dispatch() | Store InformationCreate custom block inside headerHow to call widget with products of specific category in “.phtml” file?How to call widget with products of specific category in “.phtml” file?call other layout and block in custom phtmlHow to use session and pass some value to phtml file to phtml file?Magento2: How to call custom block in phtml file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a custom phtml
inside I called attribute.phtml
but it's not working:
echo $block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml');
echo $this->getLayout()
->createBlock("MagentoFrameworkViewElementTemplate")
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
Both showing error only.
magento2 layout blocks template
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a custom phtml
inside I called attribute.phtml
but it's not working:
echo $block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml');
echo $this->getLayout()
->createBlock("MagentoFrameworkViewElementTemplate")
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
Both showing error only.
magento2 layout blocks template
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a custom phtml
inside I called attribute.phtml
but it's not working:
echo $block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml');
echo $this->getLayout()
->createBlock("MagentoFrameworkViewElementTemplate")
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
Both showing error only.
magento2 layout blocks template
I have a custom phtml
inside I called attribute.phtml
but it's not working:
echo $block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml');
echo $this->getLayout()
->createBlock("MagentoFrameworkViewElementTemplate")
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
Both showing error only.
magento2 layout blocks template
magento2 layout blocks template
edited May 19 '17 at 11:33
Siarhey Uchukhlebau
10.1k93058
10.1k93058
asked May 19 '17 at 11:05
Magento 2Magento 2
2,41172877
2,41172877
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Pass Block file as, MagentoCatalogBlockProductViewDescription
Just keep below line in your phtml file,
<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockProductViewDescription")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
add a comment |
If you want use the Magento_Catalog::product/view/attribute.phtml
you should add important data to the block before layout render it (from the template):
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
So according to your needs you can pass block arguments to the createBlock
method using third argument:
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return ElementBlockInterface
*/
public function createBlock($type, $name = '', array $arguments = []);
Your code should looks like this (I use the SKU-attribute as an example):
$block->getLayout()
->createBlock(
'MagentoFrameworkViewElementTemplate',
'',
[
"at_call" => 'getSku',
"at_code" => 'sku',
"css_class" => 'sku',
"at_label" => 'default',
"add_attribute" => 'itemprop="sku"',
"product" => $block->getProduct() // Here should be real current product, you should load it in your main block!
])
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
PS: Try to change $this
to the $block
in your code:
<?php echo ($block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml')) ;?>
<?php echo $block->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
In Magento 2 you should use the $block
variable inside a template, not $this
. Here you can find additional info.
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f175255%2fhow-to-call-phtml-inside-phtml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Pass Block file as, MagentoCatalogBlockProductViewDescription
Just keep below line in your phtml file,
<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockProductViewDescription")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
add a comment |
Pass Block file as, MagentoCatalogBlockProductViewDescription
Just keep below line in your phtml file,
<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockProductViewDescription")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
add a comment |
Pass Block file as, MagentoCatalogBlockProductViewDescription
Just keep below line in your phtml file,
<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockProductViewDescription")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
Pass Block file as, MagentoCatalogBlockProductViewDescription
Just keep below line in your phtml file,
<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockProductViewDescription")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
answered May 19 '17 at 11:11
Rakesh JesadiyaRakesh Jesadiya
30.4k1577125
30.4k1577125
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
add a comment |
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
please let me know if you have any issue
– Rakesh Jesadiya
May 19 '17 at 12:45
add a comment |
If you want use the Magento_Catalog::product/view/attribute.phtml
you should add important data to the block before layout render it (from the template):
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
So according to your needs you can pass block arguments to the createBlock
method using third argument:
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return ElementBlockInterface
*/
public function createBlock($type, $name = '', array $arguments = []);
Your code should looks like this (I use the SKU-attribute as an example):
$block->getLayout()
->createBlock(
'MagentoFrameworkViewElementTemplate',
'',
[
"at_call" => 'getSku',
"at_code" => 'sku',
"css_class" => 'sku',
"at_label" => 'default',
"add_attribute" => 'itemprop="sku"',
"product" => $block->getProduct() // Here should be real current product, you should load it in your main block!
])
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
PS: Try to change $this
to the $block
in your code:
<?php echo ($block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml')) ;?>
<?php echo $block->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
In Magento 2 you should use the $block
variable inside a template, not $this
. Here you can find additional info.
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
add a comment |
If you want use the Magento_Catalog::product/view/attribute.phtml
you should add important data to the block before layout render it (from the template):
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
So according to your needs you can pass block arguments to the createBlock
method using third argument:
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return ElementBlockInterface
*/
public function createBlock($type, $name = '', array $arguments = []);
Your code should looks like this (I use the SKU-attribute as an example):
$block->getLayout()
->createBlock(
'MagentoFrameworkViewElementTemplate',
'',
[
"at_call" => 'getSku',
"at_code" => 'sku',
"css_class" => 'sku',
"at_label" => 'default',
"add_attribute" => 'itemprop="sku"',
"product" => $block->getProduct() // Here should be real current product, you should load it in your main block!
])
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
PS: Try to change $this
to the $block
in your code:
<?php echo ($block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml')) ;?>
<?php echo $block->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
In Magento 2 you should use the $block
variable inside a template, not $this
. Here you can find additional info.
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
add a comment |
If you want use the Magento_Catalog::product/view/attribute.phtml
you should add important data to the block before layout render it (from the template):
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
So according to your needs you can pass block arguments to the createBlock
method using third argument:
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return ElementBlockInterface
*/
public function createBlock($type, $name = '', array $arguments = []);
Your code should looks like this (I use the SKU-attribute as an example):
$block->getLayout()
->createBlock(
'MagentoFrameworkViewElementTemplate',
'',
[
"at_call" => 'getSku',
"at_code" => 'sku',
"css_class" => 'sku',
"at_label" => 'default',
"add_attribute" => 'itemprop="sku"',
"product" => $block->getProduct() // Here should be real current product, you should load it in your main block!
])
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
PS: Try to change $this
to the $block
in your code:
<?php echo ($block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml')) ;?>
<?php echo $block->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
In Magento 2 you should use the $block
variable inside a template, not $this
. Here you can find additional info.
If you want use the Magento_Catalog::product/view/attribute.phtml
you should add important data to the block before layout render it (from the template):
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
So according to your needs you can pass block arguments to the createBlock
method using third argument:
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return ElementBlockInterface
*/
public function createBlock($type, $name = '', array $arguments = []);
Your code should looks like this (I use the SKU-attribute as an example):
$block->getLayout()
->createBlock(
'MagentoFrameworkViewElementTemplate',
'',
[
"at_call" => 'getSku',
"at_code" => 'sku',
"css_class" => 'sku',
"at_label" => 'default',
"add_attribute" => 'itemprop="sku"',
"product" => $block->getProduct() // Here should be real current product, you should load it in your main block!
])
->setTemplate("Magento_Catalog::product/view/attribute.phtml")
->toHtml();
PS: Try to change $this
to the $block
in your code:
<?php echo ($block->getTemplateFile('Magento_Catalog::product/view/attribute.phtml')) ;?>
<?php echo $block->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Magento_Catalog::product/view/attribute.phtml")->toHtml();?>
In Magento 2 you should use the $block
variable inside a template, not $this
. Here you can find additional info.
edited May 19 '17 at 11:26
answered May 19 '17 at 11:08
Siarhey UchukhlebauSiarhey Uchukhlebau
10.1k93058
10.1k93058
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
add a comment |
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
After addin this it break the site
– Magento 2
May 19 '17 at 11:10
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari see updated answer. Please, add error from the log to your question.
– Siarhey Uchukhlebau
May 19 '17 at 11:14
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
@Kothari still have same issues?
– Siarhey Uchukhlebau
May 30 '17 at 8:55
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f175255%2fhow-to-call-phtml-inside-phtml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown