How to add Block into another one - Magento 2 - magento

what's up!
I need a little help.
I am trying to create some blocks usign the code below:
<referenceContainer name="content">
<block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit" name="quotes_quotes_edit" template="Gysa_Quotes::quote/create/form.phtml">
<block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit\Products" template="Gysa_Quotes::quote/create/products.phtml" name="quotes_quotes_edit_products" />
</block>
</referenceContainer>
But the block "quotes_quotes_edit_products" doens't showing up. I have looked some examples on "Magento Sales" and there I can see that is possible. So What Am I doing wrong.
Anyone Can help please.
Cheers.

It might sound silly but have you cleared cache?
Also it would help to see if the block is loaded if you enable the template hints

Just Change It :-
<referenceContainer name="content">
<block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit" name="quotes_quotes_edit" template="Gysa_Quotes::quote/create/form.phtml">
name="quotes_quotes_edit_products" />
</block>
<refernceBlock name="quotes_quotes_edit">
<block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit\Products" template="Gysa_Quotes::quote/create/products.phtml"
</refernceBlock>
</referenceContainer>

Related

Adding <referenceBlock name="head.additional"> Magento 2 not working

I had these blocks in the frontend layout:
<referenceContainer name="content">
<block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofile" template="profile.phtml" cacheable="false" before="-"/>
</referenceContainer>
<referenceContainer name="sidebar.main">
<block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofileleft" template="profile_left_sidebar.phtml" cacheable="false" before="-"/>
</referenceContainer>
<referenceContainer name="sidebar.additional">
<block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofileright" template="profile_right_sidebar.phtml" cacheable="false" before="-"/>
</referenceContainer>
then i wanted to add a new block in order to insert it in the section.
I added the following command above these blocks
<referenceBlock name="head.additional">
<block class="Dfl\Marketplace\Block\Profile" name="marketplace_social_tags" template="social_tags.phtml" />
</referenceBlock>
then in my social_tags.phtml template I just added a simple meta entry.
meta entry example
Then I run setup:upgrade and setup:static-content:deploy en_US es_ES
But the entry wasn't there in the head tag.
I followed these links yet i was unable to display the meta entries.
Atwix - Adding blocks to the head section in Magento 2
add-block-in-head-tag-in-magento-2
Any help? What it's missing?
Man. I had the same problem while trying to get hreflang things in the head.
Tried for 4 hours.
Even though several sites and even an example module reference the head.additional in the default.xml - I found out, for me it was only working when using
<referenceBlock name="head.additional">
in the default_head_blocks.xml
That drived me so crazy.

cart.phtml override issue

I am trying to override cart.phtml from checkout\cart.phtml using local.xml
<layout version="0.1.0">
<checkout_cart_index translate="label">
<reference name="checkout.cart">
<action method="setTemplate"><template>test/cart.phtml</template></action>
</reference>
</checkout_cart_index>
</layout>
override works fine but when i try to empty cart it always call my cart.phtml instead of checkout\cart\noItems.phtml.
when my cart is empty then it looks like
Any help will be appreciated
Thank you
Take a look at the original checkout.xml
<block type="checkout/cart" name="checkout.cart">
<action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
<action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
It has 2 template methods - setCartTemplate and setEmptyTemplate. Add these methods and you should be golden.
The chosen answer by PixieMedia will not work as is. It is missing the essential method call: chooseTemplate. Without it the answer will not work. Read https://stackoverflow.com/a/33875491/2973534 for a thorough explanation; that post contains the proper answer.

Updating custom block in CMS page

I'm having a bit of trouble understanding how to update a custom block that I include in a CMS page.
I am using the standard shortcode in the CMS page, which works fine:
{{block type="catalog/product_list" category_id="16"
template="catalog/product/slider_list.phtml"}}
I am trying to set the column count of this custom custom block, for which I've found that I need something like the following piece of code:
<block type="catalog/product_list" name="catalog.product.slider_list"
template="catalog/product/slider_list.phtml">
<action method="setColumnCount"><columns>4</columns></action>
</block>
I'm not exactly sure under which <reference /> block I should place the code... I looked in catalog.xml, and if I try to place it between <reference name="root" />, I do not get the correct behavior.
Thank you.
Edit: use of incorrect terminology; I was calling the block static, where in fact it is a custom block.
if you want to call it on home page where the reference name should be like in your local.xml or any of the xml of your extension. just add it like below
<cms_index_index>
<reference name="content">
// your custom block
<block type="catalog/product_list" name="catalog.product.slider_list"
template="catalog/product/slider_list.phtml">
<action method="setColumnCount"><columns>4</columns></action>
</block>
</reference>
</cms_index_index>
hope this will sure help you.

how to find the links in the footer in magento

I am trying to find the links in the footer of a magento website , but i am having difficulty finding the phtml file. I found the block code in the page.xml file
<block type="page/template_links" name="footer_links" as="footer_links" after="footer.newsletter" template="page/template/links.phtml"/>
but i cannot find the file links.phtml file , i checked the current template
website/app/design/frontend/website.com/default/template/page/
but i cannot see any template folder there.
Can anybody help me please with this, how to find the file, i even tried turning on template path hints it didn't help. Thanking you for your help in advance.
It can be confusing, the footer links i Magento are generated in one of two ways:
1) Added via XML layouts, which is how the sitemap link etc are added, example:
contacts.xml
<reference name="footer_links">
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled">
<label>Contact Us</label>
<url>contacts</url>
<title>Contact Us</title>
<prepare>true</prepare></action>
</reference>
You can add more like this, or comment out to remove each link
They are generated using a standard template file (template/page/template/links.phtml) which is enabled in the config below. Each link definition as above (there's multiple in different xml configs) will use the template below to display the actual HTML link.
page.xml
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<!-- uncomment this to ditech them.. -->
<block type="page/template_links"
name="footer_links" as="footer_links"
template="page/template/links.phtml" />
</block>
2) You will find a static block called footer_links which also includes some links, this is to make it easier for you to add your own link. They are enabled inside
cms.xml
<reference name="footer">
<block type="cms/block" name="cms_footer_links" before="footer_links">
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
</reference>
Both methods are used to generate the footer links which can be confusing :)
Try this path:
/app/design/frontend/base/default/template/page/template
Hope that helps you...
to remove "orders and returns" from the footer link i had to comment out the block from sales.xml file
<!-- <default>
<reference name = "footer_links">
<block type="sales/guest_links" name="return_link"/>
<action method="addlinkBlock">
<blockName>return_link</blockName>
</action>
</reference>
</default>
-->

Adding Cart to top.menu in Magento

I'm building a navigation bar that includes the user menu and cart along with the wishlist but trying to figure out how one would add it in the xml mockup to include it using the getChildHtml function.
XML file: page.xml
<block type="page/html_header" name="header" as="header">
I have
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
Now as far as I can see I have to include the following somewhere or extend the block or something not really sure, please help me in the right direction or even point me to a developers guide that would cover this.
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
Create a file local.xml in your theme folder app/design/frontend/your_package/your_theme/layout/
add the following lines and save the file.
<layout version="0.1.0">
<default>
<reference name="top.menu">
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
</reference>
</default></layout>
Don't forget to clear magento cache(System->Cache management) after applying the change.
In order to learn more about Magento blocks ,layouts ,templates there is an official magento guide check it here

Resources