Add javascript code in payment.phtml in the Magento - magento

I have the following layout xml
<reference name="content">
<block type="gate/paycheckout" name="payair.gate.paycheckout" before="-" template="gate/checkout.phtml"/>
<block type="gate/paymentjs" name="payair.gate.paymentjs" />
</reference>
I have a block by which i am calling the javascript on the payment.phtml and its working but i want to call the Magento addJs action method to add the javascript dynamically on the payment.phtml page not by calling the block. How can i do this?

You should add the script to head:
layout xml file:
<layout>
<name_of_the_handle>
<reference name="head">
<action method="addJs"><script>gate/payment.js</script></action>
</reference>
</name_of_the_handle>
...
</layout>
payment.js file should in this case be located in js/gate/payment.js

Related

Magento showing top menu, search box and cart twice

Magento is showing the top (categories) menu, search box and cart twice.
Click Here is my site link This page shows menu search box and cart twice.
It seems to me that the header.phtml is being executed twice
here is the header xml
i took this /app/design/frontend/default/buyshop/layout/ layout.xml
topLinks
<block type="buyshopconfig/navigation" name="buyshop.collapsedmenu" as="mobileMenu"
template="page/html/mobilemenu.phtml"/>
<block type="buyshopconfig/navigation" name="buyshop.advmenu.amazing" as="advMenuamazing"
template="page/html/topmenu_amazing.phtml"/>
<reference name="top.menu">
<action method="unsetChild"><name>catalog.topnav</name></action>
<block type="buyshopconfig/navigation" name="catalog.topnav.menu" template="page/html/topmenu.phtml"/>
</reference>
<block type="directory/currency" name="currency" template="page/switch/currency.phtml"/>
<action method="insert">
<block_name_to_insert>top.links</block_name_to_insert>
<sort_relative_to_other_childname/>
<sort_before_or_after/>
<alias>topLinks</alias>
</action>
</reference>
<!--HEADER EOF-->
<reference name="left">
<action method="unsetChild">
<name>topLinks</name>
</action>
<block type="buyshopconfig/navigation" name="leftmenu" as="leftmenu" template="page/html/leftmenu.phtml" before="-"/>
</reference>
<reference name="top.links">
<block type="buyshopconfig/comparelink" name="compare_link"/>
<action method="addLinkBlock">
<blockName>compare_link</blockName>
</action>
</reference>
<!--FOOTER-->
<reference name="footer">
<block type="newsletter/subscribe" name="footer.newsletter" as="footer_newsletter" template="newsletter/subscribe.phtml"/>
</reference>
<!--FOOTER EOF-->
<remove name="catalog.leftnav" />
</default>
<cms_index_index>
<reference name="root">
how i can solve this ?? please help me thanks
.visible-desktop {
display: none !important;
}
it will work for you
try this i just tested this in firebug for you :)
I found that this problem caused by this div - . It contains this "second menu". Look through your project with this combination id="spy". You fill find phtml or php file and than module for each this belongs. If you did not find it go to Admin->System->CMS and try to find this page or static block.
Best regards!
Hi i have worked on the same theme.
Just try changing the bootstrap-responsive.css file line number 53 to this:
.visible-desktop {display: none !important}

Override AddItemRenderer default in Admin Magento Extension

I've created a magento (1.7 CE) local module to add, in the Admin section, some info to the product list displayed in the Orders received.
Internally all seems to work good except that i'm not succeeding in replacing the template used to render each product line in the order.
In app/design/adminhtml/default/default/layout/sales.xml i have this code
<adminhtml_sales_order_view>
<reference name="head">
<action method="addJs"><file>mage/adminhtml/giftmessage.js</file></action>
<action method="addJs"><file>mage/adminhtml/giftoptions/tooltip.js</file></action>
</reference>
<reference name="content">
<block type="adminhtml/sales_order_view" name="sales_order_edit"></block>
</reference>
<reference name="left">
<block type="adminhtml/sales_order_view_tabs" name="sales_order_tabs">
<block type="adminhtml/sales_order_view_tab_info" name="order_tab_info" template="sales/order/view/tab/info.phtml">
<block type="adminhtml/sales_order_view_messages" name="order_messages"></block>
<block type="adminhtml/sales_order_view_info" name="order_info" template="sales/order/view/info.phtml"></block>
<block type="adminhtml/sales_order_view_items" name="order_items" template="sales/order/view/items.phtml">
<action method="addItemRender"><type>default</type><block>adminhtml/sales_order_view_items_renderer_default</block><template>sales/order/view/items/renderer/default.phtml</template></action>
<...
I would like to replace the template set by the LAST line you see (the addItemRenderer).
In my module config.xml i have
<adminhtml>
<layout>
<updates>
<my_ext>
<file>myext_update.xml</file>
</my_ext>
</updates>
</layout>
</adminhtml>
and in app/design/adminhtml/default/default/layout/myext_update.xml i have
<?xml version="1.0"?>
<admin_sales_order_view>
<reference name="left">
<reference name="sales_order_tabs">
<reference name="order_tab_info">
<reference name="order_items">
<action method="addItemRender">
<type>default</type>
<block>adminhtml/sales_order_view_items_renderer_default</block>
<template>myext/sales/order/view/items/renderer/default.phtml</template>
</action>
</reference>
</reference>
</reference>
</reference>
</admin_sales_order_view>
Obviously i have the file in app/design/adminhtml/default/default/template/myext/sales/order/view/items/renderer/default.phtml
but it is still not used.
Do you have a solution?
Found the solution after some day of struggling...
the code and the method is all good, but i mistyped the handle name to update in the myext_update.xml
i wrote
<admin_sales_order_view>
but , as in the original sales.xml, the handle name was
<adminhtml_sales_order_view>
Actually this wont work as the way you proceeded. You need to update the layouts.
Have some idea about layout updates also render the layout in yout module
Check here http://www.magentocommerce.com/design_guide/articles/intro-to-layouts

Create a module in magento

I have followed the magento tutorials to create a module. In the 3rd part "Part 3 - Magento Controller Dispatch". I have no problem to create a module.But in the Part 4, i am confusing about the layout,
How to create a page template in magento is written there.But, When i followed the code "create a file at"
app/design/frontend/base/default/layout/local.xml
I have already the local.xml file in my theme. So i confused where can i create the file and add the lines
<layout version="0.1.0">
<default>
<block type="page/html" name="root" output="toHtml" template="magentotutorial/helloworld/simple_page.phtml" />
</default>
</layout>
I have already the local.xml file where the following lines are written.
left.permanent.callout
<reference name="right">
<action method="unsetChild"><name>right.permanent.callout</name></action>
<remove name="paypal.partner.right.logo"/>
</reference>
<reference name="root">
<remove name="global_messages" />
</reference>
<reference name="content">
<block type="core/template" name="alert_global_messages" template="core/messages.phtml" before="-" />
</reference>
<reference name="before_body_end">
<block type="core/template" name="jquery_noconflict" template="jquery/noconflict.phtml" before="-" />
</reference>
Now, how can i add the line
in my local.xml file.

Magento delete product compare

I use magento and I have my own template but on my product detail page on the left side I have compare products. How can I delete this block?
Just create local.xml file under your theme/layout/local.xml and place below code.
<layout version="0.1.0">
<default>
<!-- remove compare products -->
<remove name="catalog.compare.sidebar" />
</default>
</layout>
This block is added in layout files. You can remove this block in original files or in your extension layout.
By default this block is added in files
/app/design/frontend/base/default/layout/catalog.xml
/app/design/frontend/base/default/layout/customer.xml
1) Copy this files to your theme folder and remove strings
<block type="catalog/product_compare_sidebar" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
2) In your layout file add lines
<default>
<reference name="right">
<action method="unsetChild"><name>catalog.compare.sidebar</name></action>
</reference>
<reference name="left">
<action method="unsetChild"><name>catalog.compare.sidebar</name></action>
</reference>
</default>
<customer_account>
<reference name="left">
<action method="unsetChild"><name>catalog.compare.sidebar</name></action>
</reference>
<reference name="right">
<action method="unsetChild"><name>catalog.compare.sidebar</name></action>
</reference>
</customer_account>
To completely disable compare products functionality you can use this free extension.
Just remove the file /app/design/frontend/base/default/template/catalog/product/compare/sidebar.html or rename it.
Just remove this block from layout/catalog.xml and compare products section will be gone :
<reference name="left">
<block type="catalog/product_compare_sidebar" after="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
</reference>

Removing links from top menu using local.xml

Does anyone know how I can remove links from the top menu using local.xml.
In the default checkout.xml there is:
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCartLink"></action>
<action method="addCheckoutLink"></action>
</block>
</reference>
And I would like to remove the addCartLink from the top menu. One way would be just edit the checkout.xml file, but it think it would be a much better solution just to add the remove to my local.xml file, but I can't seem to get the right name to remove. If I do a
<layout>
<default>
<remove name="top.links" />
</default>
</layout>
That does remove the entire menu, but how do I remove just a single item from the menu using locale.xml?
I am using Magento 1.6
You can do this in local.xml:
<default>
<reference name="top.links">
<action method="removeLinkByUrl">
<url helper="checkout/url/getCartUrl" />
</action>
</reference>
</default>
It was also my question How can i get the full path in local.xml file
<default>
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link"/>
<action method="removeLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>
</default>
Add this part to your local.xml. Writing this under default will remove it from every page. So adjust it accordingly. I hope this will help you.
It should be:
<layout>
<default>
<reference name="top.links">
<reference name="checkout_cart_link">
<remove name="top-link-cart" />
</reference>
</reference>
</default>
</layout>
But you can always copy the checkout.xml in your local theme and edit it.
<default>
<reference name="top.links">
<remove name="wishlist_link"/>
</reference>
</default>
Add this part to your local.xml. That works for me. Just use "remove". That's it.
You can remove a link via layout update either
by its name | calling removeLinkBlock($blockName)
by its url | calling removeLinkByUrl($url)
overwriting the file were it was added
The functions live in Mage_Page_Block_Template_Links
Option 1
The removeLinkByUrl() function needs an url as parameter which will usually provided by a helper function in the respective extension. Just grab it there and you can use something like
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="customer/getRegisterUrl"/></action>
</reference>
In above case customer is the extensions name while getRegisterUrl is the function in the helper class.
If your extension isn't providing any function which is returning a link you can try following
<reference name="top.links">
<action method="removeLinkByUrl"><url>ADD_THE_DYNAMIC_LINK_HERE</url></action>
</reference>
Option 2
If the link was added with a name, like
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link" />
<action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>
you can just use
<reference name="top.links">
<remove name="wishlist_link"/>
</reference>
or
<default>
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link"/>
<action method="removeLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>
</default>
Option 3
If your link wasn't added with a name and a hardcoded url doesn't work for some reason you can just go ahead and copy the modules layout.xml to your custom theme folder and remove the lines where the link was added.
Hi This removes both the cart and checkout links from top.links in 1.9.3
<reference name="top.links">
<action method="removeLinkByUrl">
<url helper="checkout/url/getCartUrl" />
</action>
<action method="removeLinkByUrl">
<url helper="checkout/url/getCheckoutUrl" />
</action>
</reference>
based on the best accepted answer above but just in case anyone wants to remove both

Resources