magento 2 createBlock from argument itemHow to change admin login template in Magento 1.5 or 1.6What's the correct way to add a CMS block to a template fileHow can i rewrite TierPrice Block in Magento2Template file isn't inheriting from my block extending Mage_Core_Block_Template?Magento 2.0.x - Insert block in to the product pageHow to create a custom block from billing.phtmlcreateBlock() and setChild() in magento 2Magento 2.1: how to remove argument and/or argument item from block?Magento 2.2.0 - checkout_index_index.xml shippingAdditional not workingGrid action column custom callback with multiple params in magento2
What mechanic is there to disable a threat instead of killing it?
How to tell a function to use the default argument values?
iPad being using in wall mount battery swollen
Is this a hacking script in function.php?
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
Extract rows of a table, that include less than x NULLs
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
Forgetting the musical notes while performing in concert
Valid term from quadratic sequence?
Am I breaking OOP practice with this architecture?
What is a romance in Latin?
Determining Impedance With An Antenna Analyzer
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
Why didn't Miles's spider sense work before?
Can a virus destroy the BIOS of a modern computer?
How writing a dominant 7 sus4 chord in RNA ( Vsus7 chord in the 1st inversion)
In 'Revenger,' what does 'cove' come from?
Which is the best way to check return result?
Detention in 1997
How dangerous is XSS?
Intersection Puzzle
Expand and Contract
How do I handle a potential work/personal life conflict as the manager of one of my friends?
How to prevent "they're falling in love" trope
magento 2 createBlock from argument item
How to change admin login template in Magento 1.5 or 1.6What's the correct way to add a CMS block to a template fileHow can i rewrite TierPrice Block in Magento2Template file isn't inheriting from my block extending Mage_Core_Block_Template?Magento 2.0.x - Insert block in to the product pageHow to create a custom block from billing.phtmlcreateBlock() and setChild() in magento 2Magento 2.1: how to remove argument and/or argument item from block?Magento 2.2.0 - checkout_index_index.xml shippingAdditional not workingGrid action column custom callback with multiple params in magento2
My custom module xml file contains the block code. I want to call that block code directly using createBlock method and set template to show in specific template. My block code is adding animated fancing lines to form.
If i mention in xml using following format then it works fine. How can i display same block using createBlock method?
<referenceContainer name="form.contact.additional.info">
<block class="JacksonWyssBlockFrontendWyss" name="Wyss-reca" after="-"
template="Jackson_Wyss::wyss.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="wyssdata" xsi:type="array">
<item name="component" xsi:type="string">Jackson_Wyss/js/reca</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
for example:
$block->getLayout()->createBlock('JacksonwyssBlockFrontendReca')->setData('jsLayout', '5')->setTemplate('goodtest/test.phtml')->toHtml();
In above xml code zone is form type name. I want to set different name for all the forms in createBlock method. is there anyway we can createBlock method for above xml code?
How can i make createBlock method of my above xml code?
magento2 layout magento2.2 blocks
add a comment |
My custom module xml file contains the block code. I want to call that block code directly using createBlock method and set template to show in specific template. My block code is adding animated fancing lines to form.
If i mention in xml using following format then it works fine. How can i display same block using createBlock method?
<referenceContainer name="form.contact.additional.info">
<block class="JacksonWyssBlockFrontendWyss" name="Wyss-reca" after="-"
template="Jackson_Wyss::wyss.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="wyssdata" xsi:type="array">
<item name="component" xsi:type="string">Jackson_Wyss/js/reca</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
for example:
$block->getLayout()->createBlock('JacksonwyssBlockFrontendReca')->setData('jsLayout', '5')->setTemplate('goodtest/test.phtml')->toHtml();
In above xml code zone is form type name. I want to set different name for all the forms in createBlock method. is there anyway we can createBlock method for above xml code?
How can i make createBlock method of my above xml code?
magento2 layout magento2.2 blocks
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday
add a comment |
My custom module xml file contains the block code. I want to call that block code directly using createBlock method and set template to show in specific template. My block code is adding animated fancing lines to form.
If i mention in xml using following format then it works fine. How can i display same block using createBlock method?
<referenceContainer name="form.contact.additional.info">
<block class="JacksonWyssBlockFrontendWyss" name="Wyss-reca" after="-"
template="Jackson_Wyss::wyss.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="wyssdata" xsi:type="array">
<item name="component" xsi:type="string">Jackson_Wyss/js/reca</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
for example:
$block->getLayout()->createBlock('JacksonwyssBlockFrontendReca')->setData('jsLayout', '5')->setTemplate('goodtest/test.phtml')->toHtml();
In above xml code zone is form type name. I want to set different name for all the forms in createBlock method. is there anyway we can createBlock method for above xml code?
How can i make createBlock method of my above xml code?
magento2 layout magento2.2 blocks
My custom module xml file contains the block code. I want to call that block code directly using createBlock method and set template to show in specific template. My block code is adding animated fancing lines to form.
If i mention in xml using following format then it works fine. How can i display same block using createBlock method?
<referenceContainer name="form.contact.additional.info">
<block class="JacksonWyssBlockFrontendWyss" name="Wyss-reca" after="-"
template="Jackson_Wyss::wyss.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="wyssdata" xsi:type="array">
<item name="component" xsi:type="string">Jackson_Wyss/js/reca</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
for example:
$block->getLayout()->createBlock('JacksonwyssBlockFrontendReca')->setData('jsLayout', '5')->setTemplate('goodtest/test.phtml')->toHtml();
In above xml code zone is form type name. I want to set different name for all the forms in createBlock method. is there anyway we can createBlock method for above xml code?
How can i make createBlock method of my above xml code?
magento2 layout magento2.2 blocks
magento2 layout magento2.2 blocks
asked 2 days ago
Dipen VyasDipen Vyas
284
284
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday
add a comment |
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday
add a comment |
1 Answer
1
active
oldest
votes
Try using calling as ChildBlock, like the bellow example:
<!-- Add Instant purchase on Recently viewed products -->
<referenceBlock name="catalog.product.related" >
<block name="product.info.addtocart.instantPurchase.additional.recently" class="MagentoInstantPurchaseBlockButton" template="Magento_InstantPurchase::button.phtml" before="-">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="instant-purchase" xsi:type="array">
<item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_InstantPurchase/instant-purchase</item>
</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceBlock>
In parent .phtml:
<?php
if($block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently', true))
$block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently')->setProduct($_product);
echo $block->getChildHtml('product.info.addtocart.instantPurchase.additional.recently', false);
?>
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%2f268176%2fmagento-2-createblock-from-argument-item%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try using calling as ChildBlock, like the bellow example:
<!-- Add Instant purchase on Recently viewed products -->
<referenceBlock name="catalog.product.related" >
<block name="product.info.addtocart.instantPurchase.additional.recently" class="MagentoInstantPurchaseBlockButton" template="Magento_InstantPurchase::button.phtml" before="-">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="instant-purchase" xsi:type="array">
<item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_InstantPurchase/instant-purchase</item>
</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceBlock>
In parent .phtml:
<?php
if($block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently', true))
$block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently')->setProduct($_product);
echo $block->getChildHtml('product.info.addtocart.instantPurchase.additional.recently', false);
?>
add a comment |
Try using calling as ChildBlock, like the bellow example:
<!-- Add Instant purchase on Recently viewed products -->
<referenceBlock name="catalog.product.related" >
<block name="product.info.addtocart.instantPurchase.additional.recently" class="MagentoInstantPurchaseBlockButton" template="Magento_InstantPurchase::button.phtml" before="-">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="instant-purchase" xsi:type="array">
<item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_InstantPurchase/instant-purchase</item>
</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceBlock>
In parent .phtml:
<?php
if($block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently', true))
$block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently')->setProduct($_product);
echo $block->getChildHtml('product.info.addtocart.instantPurchase.additional.recently', false);
?>
add a comment |
Try using calling as ChildBlock, like the bellow example:
<!-- Add Instant purchase on Recently viewed products -->
<referenceBlock name="catalog.product.related" >
<block name="product.info.addtocart.instantPurchase.additional.recently" class="MagentoInstantPurchaseBlockButton" template="Magento_InstantPurchase::button.phtml" before="-">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="instant-purchase" xsi:type="array">
<item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_InstantPurchase/instant-purchase</item>
</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceBlock>
In parent .phtml:
<?php
if($block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently', true))
$block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently')->setProduct($_product);
echo $block->getChildHtml('product.info.addtocart.instantPurchase.additional.recently', false);
?>
Try using calling as ChildBlock, like the bellow example:
<!-- Add Instant purchase on Recently viewed products -->
<referenceBlock name="catalog.product.related" >
<block name="product.info.addtocart.instantPurchase.additional.recently" class="MagentoInstantPurchaseBlockButton" template="Magento_InstantPurchase::button.phtml" before="-">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="instant-purchase" xsi:type="array">
<item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_InstantPurchase/instant-purchase</item>
</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceBlock>
In parent .phtml:
<?php
if($block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently', true))
$block->getChildBlock('product.info.addtocart.instantPurchase.additional.recently')->setProduct($_product);
echo $block->getChildHtml('product.info.addtocart.instantPurchase.additional.recently', false);
?>
answered 2 days ago
Narendra VyasNarendra Vyas
35911
35911
add a comment |
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%2f268176%2fmagento-2-createblock-from-argument-item%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
You can try using as childblock. Add this block as as child where in you want to call and then call using getChildBlock
– Narendra Vyas
2 days ago
Thanks for your reply. So if i call it using the childBlock will it consider the paramaters defined under the (in your example)<item name="instant-purchase" xsi:type="array"> <item name="component" xsi:type="string">Magento_InstantPurchase/js/view/instant-purchase</item> <item name="config" xsi:type="array"> I want to make sure that in zone (in my code) applied there.
– Dipen Vyas
2 days ago
Yes it do. I have used it as mentioned in below code. YOu can try and let me know if in case of any issue
– Narendra Vyas
yesterday