I have a order timeline page on frontend at :
/magento/app/design/frontend/default/mytheme/template/sales/order/info.phtml
I am trying to use the same page on adminhtml, from sales -> orders on a single view order page I am creating a hyperlink on click of that I would like to show a popup that will display the timeline same as displayed on frontend page of info.phtml. Can I use the same template info.phtml I have in frontend or I have to create one more for backend? also any ideas how to approach this? thanks
I have created a black in
magento/app/design/adminhtml/default/default/layout/sales.xml and added the template code of info.phtml in timeline.phtml
<adminhtml_sales_order_timeline>
<block type="adminhtml/sales_order_timeline" name="timeline_tracking" template="sales/order/view/timeline.phtml"></block>
</adminhtml_sales_order_timeline>
Edit :
The request is going to the controller :
public function timelineAction()
{
$this->loadLayout();
$this->renderLayout();
}
which loads the following layout :
<adminhtml_sales_order_timeline>
<remove name="header" />
<remove name="footer" />
<block type="adminhtml/sales_order_timeline" name="sales_order_timeline" template="sales/order/timeline/timeline.phtml" />
</adminhtml_sales_order_timeline>
this removes the header and footer but this is not displaying the content of the template timeline.phtml, I have not done any other configurations for block, what am I missing?
your Admin layouts will look for the phtmls inside adminhtml/ folder and not the frontend/ folders. What you can do is copy the info.phtml inside your adminhtml/default/default/template/your_folder_name and include that in your adminhtml layout.
Related
I am trying to call Magento customer registration form on my home page. When I call it on the home page I try both ways, static block or template.phtml file and my site stops working. Can anyone suggest a solution to me?
<?php
echo $this->getLayout()->createBlock('cms/block')->setBlockId('register-form')->toHtml();
<?php
echo $this->getLayout()->createBlock('core/template')->setTemplate('persistent/customer/form/mini.register')->toHtml();
when using a template file, add the '.phtml' extension to the name of the file.
in your example:
echo $this->getLayout()->createBlock('core/template')->setTemplate('persistent/customer/form/mini.register.phtml')->toHtml();
please not that the code above will only work in template files.
if you are trying to add this to your homepage through the admin cms page, then you would do this:
{{ block type="core/template" template="persistent/customer/form/mini.register.phtml" }}
or through a layout file:
<block type="core/template" template="persistent/customer/form/mini.register.phtml" />
I want to call a block in content of home page. I am writing a code like that:
{{block type='blog/menu_sidebar' template='latest_blog/latest-blog.phtml'}}
But phtml file is not coming in home page.
On the other hand when I call block in layout update xml under under the design tab by writing the code like that :
<block type="blog/menu_sidebar" name="right.blog">
<action method="setTemplate" >
<template>latest_blog/latest-blog.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
Then the phtml file is coming in home page.
My problem is that i want to include latest-blog.phtml file in the content of home page because I will have to play with the div structure for designing which i can not play in the layout section.
You can use getLayout() function
<?php echo $this->getLayout()
->createBlock("blog/menu_sidebar")
->setTemplate("latest_blog/latest-blog.phtml")
->toHtml(); ?>
This way u can load. if you have any option you can set by calling
->setCustomOption($optionValue)
In Magento how to call a phtml file in cms page to set page title which title I set in my phtml file? I am using
$this->getLayout()->getBlock('head')->setTitle('your title');
to set page title.
To call a phtml file in a cms page or cms static block:
{{block type="core/template" template="templateFolder/your_template.phtml"}}
If you know, where the block file(php file) for your phtml file resides, then you can use it as type.
Example: Suppose you want to call new.phtml file that resides in catalog/product folder, and you know that its corresponding Block file(php file) resides in Catalog/Product folder, then you can use:
{{block type="catalog/product" template="catalog/product/new.phtml"}}
More reading: here
Hope this helps!
You cannot change the title of the page from a template file when using it in a cms block or cms page because the head block is already rendered when the page (or block) content is parsed.
It's not possible to change page title from phtml file of cms pages as already told by #Marius
you need to add to it's design in cms page as given below :
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
Add the below XML piece under CMS > Pages > Manage Content > Select a specific CMS Page
Navigate to "Design" tab > Layout Update XML >
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
Make sure the CACHE folders are DELETED under below:
{Root Magento Folder}/var/cache
{Root Magento Folder}/var/full_page_cache
Hope this helps!
Happy Coding...
In Magento how to call a phtml file in cms page to set page title which title I set in my phtml file? I am using
$this->getLayout()->getBlock('head')->setTitle('your title');
to set page title.
To call a phtml file in a cms page or cms static block:
{{block type="core/template" template="templateFolder/your_template.phtml"}}
If you know, where the block file(php file) for your phtml file resides, then you can use it as type.
Example: Suppose you want to call new.phtml file that resides in catalog/product folder, and you know that its corresponding Block file(php file) resides in Catalog/Product folder, then you can use:
{{block type="catalog/product" template="catalog/product/new.phtml"}}
More reading: here
Hope this helps!
You cannot change the title of the page from a template file when using it in a cms block or cms page because the head block is already rendered when the page (or block) content is parsed.
It's not possible to change page title from phtml file of cms pages as already told by #Marius
you need to add to it's design in cms page as given below :
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
Add the below XML piece under CMS > Pages > Manage Content > Select a specific CMS Page
Navigate to "Design" tab > Layout Update XML >
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
Make sure the CACHE folders are DELETED under below:
{Root Magento Folder}/var/cache
{Root Magento Folder}/var/full_page_cache
Hope this helps!
Happy Coding...
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!