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" />
Related
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.
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)
I have added the 2 static block codes to a CMS page in magento inside a DIV.
<div class="WTcontainerTop">
{{block type="cms/block" block_id="TW_intro"}}
{{block type="cms/block" block_id="TW-Tour"}}
</div>
After saving the page, it looks like the below although the frontend page looks fine.
<div class="WTcontainerTop">http://everydaycashmere.com/index.php/admin/cms_wysiwyg/directive/___directive/e3tibG9jayB0eXBlPSJjbXMvYmxvY2siIGJsb2NrX2lkPSJUV19pbnRybyJ9fQ,,/key/ba3c67e3bc929ae08551768624139371/ {{block type="cms/block" block_id="TW-wardrobe-Grand-Tour"}}</div>
I have tried to fix in a number of times and I don't get this error on other pages. Can anyone help please.
I don't know that the method of adding static block you tried is correct or not.You can do it by:
Clicking on "Insert Widget" on "Content" portion of 'CMS Page'.
Then select the Widget type to "CMS static Block".Then select the static block you want to add.
This process will add a static block in your cms page.
Hope this will help.
The thing is that I have logo displayed on only homepage in Magento checking if it's homepage with getIsHomepage();. Now the thing I want to do is to display logo inside header only on Dashboard page, do you know any alternative to getIsHomepage but to check if it's My account page?
Thanks
It's best practice to use xml to do this instead of parsing url. Add this to your local.xml:
<customer_account_index>
<reference name="header">
<action method="setTemplate"><template>page/html/customer_account_header.phtml</template></action>
</reference>
</customer_account_index>
And copy and edit your header.phtml file to template/page/html/customer_account_header.phtml
If you want to out logic for customer account page then
First fetch current routers and controllers and action to headere.phtml
logic is like
for magento customer dasboard page url is customer/account/index
then
<?php $action = Mage::app()->getFrontController()->getAction();
echo $action->getFullActionName('_');
if($action->getFullActionName('_')=="customer_account_index")
{
}
?>
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!