I am working on a custom module. I want to use order item block in my custom module's custom email.
Here is my local.xml in my theme layout.
<recurring_email_order_items>
<block type="sales/order_email_items" name="items" template="recurring/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>recurring/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>recurring/default.phtml</template></action>
</block>
I have copied items.phtml, default.phtml and grouped.phtml from base to my them folder.
And below is my email template :
{{layout handle="recurring_email_order_items" order=$order}}
Email is sending out but without order data. Seems I am not passing $order object to handler.
Does anybody know, what I am doing wrong here?
I changed it a bit,
sent order id from controller to block using
$this->getLayout()->getBlock('recurring_subscribe')->setOrderId($orderId);
Get order id by using $this->getOrderId();
Load order by Mage::getModel('sales/order')->load($_orderId); in view and utilize.
Related
I've built a custom shopping cart for my Magento site that sends and API call to Shopify to handle payment.
The problem is I need the template file to load on every page in magento. I thought after_body_start would be a good place to put the template, but I cannot get it to load!
My template lives in \app\design\frontend\rwd\crystal\template\mgw\mwCart.phtml
and contains php, html and javascript. It was running just fine when I placed the code directly into the header.phtml
Here's the xml in \app\design\frontend\rwd\crystal\layout\local.xml which should load the template
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="after_body_start">
<block type="core/template" name="mwCart" template="mgw/mwCart.phtml" output="toHtml" before="-" />
</reference>
</default>
</layout>
I'm new to Magento and have read through the tutorials. I also checked out and tried any suggestions I could find.
I've seen this Magento - Add Some HTML on All Pages of my Theme After_Body_Start but did not solve my issue.
How can I get my template to load on every page?
Thank you.
You're close here... It the location of your local.xml file that is the problem. Place the existing file in the following location:
app/design/frontend/rwd/default/layout/local.xml
..and it should solve the problem. If you have an existing subtheme, e.g. rwd/mytheme, the file would go here:
app/design/frontend/rwd/mytheme/layout/local.xml
If you still aren't getting the desired results, check the configuration in Magento Admin->Configuration->Design->Themes and make sure that you are indeed using the rwd theme. If all else fails, the base/default location would be the last thing to try:
app/design/frontend/base/default/layout/local.xml
Sales Order View in Admin panel
This is the layout.xml
<layout>
<adminhtml_sales_order_view>
<reference name="order_tab_info">
<block type="booking/sales_order_view_reservationbooking" name="reservationbooking" template="booking/sales/order/view/reservationbooking.phtml" />
</reference>
</adminhtml_sales_order_view>
This is the block in my module
<?php
class Actino_Booking_Block_Adminhtml_Sales_Order_View_Reservationbooking extends Mage_Core_Block_Template {
}
Here is my explanation about what i want to achieve
In core adminhtml i edited the sales/order/view/info.phtml.. I know that Never edit the core files, but this is only for test for which i want to display my template around the orders view. and then if this works I should have to create or rewrite the info.phtml.
here is my custom reservationbooking.phtml
and in info.phtml i write a code to view this layout
<?php echo $this->getChildHtml('reservationbooking');?>
This is not working. I cant see the text "reservation booking data" in sales order view. without modifying any core files ?
My question is how to add custom field in sales order view ?
Once a try
<adminhtml_sales_order_view>
<reference name="order_info">
<action method="setTemplate">
<template>yourmodule/sales/order/view/reservationbooking.phtml</template>
</action>
</reference>
</adminhtml_sales_order_view>
Create a file in the following
app/design/adminhtml/default/default/template/yourmodule/sales/order/view/reservationbooking.phtml
Now you can add your stuff to the reservationbooking.phtml inside your module, without change the core files
I am stuck a little with following problem:
I created a Fom in the adminhtml area using the pure php from Magento and standard template.
This all works as expected, but I cannot dynamically add and remove fields, I need Javascript and my own phtml file for that.
My Idea now was to simply include a childblock which is using a custom template at the end of the form.
So far I have added
$cblock =$this->getLayout()
->createBlock('netcon_konmod/adminhtml_caps_edit_mat')
->setTemplate('netcon_konmod_mat.phtml');
$this->_addContent($this->getLayout()
->createBlock('netcon_konmod/adminhtml_caps_edit')->setChild($cblock));
to my controller, created an empty Netcon_Konmod_Block_Adminhtml_Caps_Edit_Mat class which extends Mage_Adminhtml_Block_Widget
and created template file mat.phtml in .../template/netcon/konmod/
I also have my konmod.xml which updates my layout and which includes
<adminhtml_caps_edit>
<reference name="content">
<block type="netcon_konmod/adminhtml_caps_edit" name="netcon_konmod_caps_edit">
<block type="netcon_konmod/adminhtml_caps_edit_mat" name="netcon_konmod_caps_mat" template="netcon_konmod_mat.phtml" />
</block>
</reference>
</adminhtml_caps_edit>
I am rather new to Magento, and until now I only found ways to include a child block by calling getChildHtml from an already existing phtml file of the parent block.
However, since I create my form completely with the form and fieldset methods, I don't have my own phtml file in which I could include that call.
The way I have it set up right now, it is displaying the form normally, but does not include the childblock.
Any help would be appreciated, if it is at all possible to do this, I would like to avoid recoding my whole form as template.
Try
$childBlock = $this->getLayout()
->createBlock('konmod/adminhtml_caps_edit_mat')
->setTemplate('netcon_konmod_mat.phtml');
$this->_addContent($this->getLayout()
->createBlock('konmod/adminhtml_caps_edit')
//->setTemplate('netcon_konmod_mat.phtml')
->append($childBlock));
I am trying to change Top links structure. I don't want to mess with xml files in default theme. I have only one xml file with everything inside. I don't want to create multiple xml files in my theme layout folder. I am trying to unset action inside top.links block.
This is the way I am trying to do:
<reference name="top.links">
<action method="unsetChild"><child>addLink</child></action>
<!-- <remove name="checkout_cart_link" /> -->
</reference>
When I put remove tag it works perfectly. But when I try to do unsetChild for addLink action it doesn't work. Do you know maybe how I should figure this out. I don't want separate xml files with the same names as in default theme.
The unsetChild function is from the Abstract block model and is used for removing a block that is a child of the current block. The block with the name top.links doesn't have a child block that is called addLink, hence the fact your configuration doesn't do anything. The action nodes with the method addLink call the addLink function on the Mage_Page_Block_Template_Links block. If the objective is to remove one of the links, you will need to use the action removeLinkByUrl.
<reference name="top.links">
<action method="removeLinkByUrl"><url>link/here</url></action>
</reference>
The exact arguments will obviously depend on what link you are attempting to remove.
I'm developing a widget for Magento, in this widget i need to load the magento contact form. I've tried several options, but none of them seem to work.
the widget is located in
app/
code/
local/
CompanyName/
WidgetName/
and the phtml files are located in
app/
design/
frontend/
default/
default/
template/
templatename/
templatefile1.pthml
templatefile2.pthml
templatefile3.phtml
to load the magento contact form i've added this in templatefile3.phtml
<?php echo $this->getChildHtml('contactForm') ?>
but it's not showing up, even after adding xml to 2 files, i've added this line into app/design/frontend/base/default/layout/catalog.xml, right below <reference name="content">
<block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"/>
and also added this code to app/design/frontend/base/default/layout/default.xml (this file didn't even exist)
<default>
<cms_page>
<reference name="content">
<block type="core/template" name="contactForm" as="contactForm" template="contacts/form.phtml">
<action method='setBlockId'><block_id>contactForm</block_id></action>
</block>
</reference>
</cms_page>
I have the idea i'm not putting the xml in the right files, but i have no idea witch files to use otherwise, and can't find any other tips than these two on the internet.
Can someone help me out?
You can add the contact form to any CMS page using CMS tags like this inside the CMS content box:
{{block type="core/template" name="contactForm" template="contacts/form.phtml"}}
You could create a new page, and then inssert that snippet to show the contact form on this new page.
you could also make a copy of form.phtml and modify it for your needs, and update the tag code to use the new template.
Please use the following function to display inside templates.
<?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Contact::form.phtml")->toHtml(); ?>
You can't just create a default.xml - to let Magento know that that a layout xml file exists you'd have to go through and create a module and specify the layout file's location. that is a very long winded way round of trying to achieve what you need.
Also I believe the handle <cms_page> is not supported. Referencing a block in a CMS page is best done by placing your xml in the layout update section under the 'design' tab for that CMS page.
So it's fairly straight forward to put the contact form into a CMS page - again use the layout update facility. Simply enter the following xml...
<reference name="content">
<block type="core/template" name="contactForm" template="contacts/form.phtml"/>
</reference>
Note you don't need a layout handle - Magento already knows of course the specific CMS page you are inserting content into because this is a layout update for that page. So in the above you are just referencing the structural block you want to add to (in this case content) and telling Magento to add the contactForm block along with its associated template location.
I've worked on a site using this method before. you will likely find that once you have called the contactform into your CMS page, and despite appearing successfully in a browser, the form doesn't actually post. In fact the form will only send if used from the intended page yoursite.com/contacts
Simple fix. Create the file app/design/frontend/YOUR-PACKAGE/YOUR-THEME/template/contacts/form.phtml and duplicate the required content from the default form.phtml into it.
Change the script at the bottom of the form.phtml file from:
<script type="text/javascript">
var contactForm = new VarienForm('contactForm', true);
</script>
To:
<script type="text/javascript">
elem = $("contactForm");
elem.writeAttribute('action', '/contacts/index/post');
</script>
And your CMS page contact form will now post as required.
Just as an addition (you may or may not find this useful).
I had a need for the contact form on my CMS page to be different from the standard form which appears on contacts. This is really simple too using the method above.
Duplicate the file app/design/frontend/YOUR-PACKAGE/YOUR-THEME/template/contacts/form.phtml and rename as something like app/design/frontend/YOUR-PACKAGE/YOUR-THEME/template/contacts/customForm.phtml - then make your required amends like different fields etc...
now in the layout update for the CMS page you want it to appear in simply add the following xml:
<reference name="content">
<block type="core/template" name="customContactForm" template="contacts/customForm.phtml"/>
</reference>
And that's it.
Note how the block name has changed - the block name can literally be anything - Magento doesn't care what you call it but I would obviously recommend something logical!