ColorBox integration in Magento - magento

I want to add ColorBox jQuery in my Magento website. Is there an specific method for this?
Or do I have to make the changes in .phtml files?

To add new javascript library on all your pages use layouts. Create new layout file yourmodule.xml and put there code
<default>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/colorbox.js</name><params/></action>
<action method="addItem"><type>skin_css</type><name>js/colorbox.css</name></action>
</reference>
</default>

Related

overriding cart.phtml issue not working for notitems.phtml

Hello i working on overriding the cart.phtml and it is working fine. but the problem is that when no item left in the cart still the it showing the cart table header and footer section without any item. i want when no item is present in the cart then it will show the noitem.phtml content as it is working for default magetno functionality.
i have check many things but not working . i have update my layout.xml but not effect any thing.
My layout.xml
<layout version="0.1.0">
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setTemplate"><template>itemdeletion/cart.phtml</template></action>
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>itemdeletion/cart/item/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>itemdeletion/cart/item/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>itemdeletion/cart/item/default.phtml</template></action>
</reference>
</checkout_cart_index>
</layout>
it is working for cart items but i make few more R & D and try to figure out how i can make it but i have get to add below blocks in xml
<action method="setEmptyTemplate"><value>itemdeletion/cart/noItems.phtml</value></action>
<action method="chooseTemplate"/>
but still it not working. Please help me out in this.
Thanks in advance

Load external Javascript before skin Javascript in Magento

I'm trying to add the Google Maps Javascript API to my Magento module.
The problem I'm having is that the core/text block that I am including, that contains the external Javascript inclusion tag, only ever appears after all of the addJs actions.
This means the script I have in pvtl_stores.js that targets the google object doesn't work as the google object hasn't been initialized yet.
Here is my local.xml file:
<layout>
<default>
<reference name="head">
<block type="core/text" name="google.maps" before="root">
<action method="setText">
<text><![CDATA[<script src="//maps.googleapis.com/maps/api/js"></script>]]></text>
</action>
</block>
<action method="addItem">
<type>skin_js</type>
<name>js/pvtl_stores.js</name>
</action>
</reference>
</default>
</layout>
Is there a way to have the core/text block load before the addJs actions?
By the way, if it isn't obvious by the question, I'm new to Magento programming!
upload you Js in root\js folder. And call this code in your app\design\frontend\base\default\template\page\html\head.phtml file at top.
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS)."/yourjs.js"; ?>
or just direct call that
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
UPDATE
You have to download the js first then
go to app\design\frontend\rwd\default\layout page.xml (if you are using default theme otherwise go to yourtheme\default\layout) and you js here
<block type="page/html_head" name="head" as="head">
<action method="addJs">
<script>yourjs/yourjs.js</script>
</action>
<action method="addJs">
<script>prototype/prototype.js</script>
</action>

Magento different cms home for themes

we use a custom template and try to add rwd template for mobile use.
We add an exception for the mobile devices but need now to use an different "home" cms for the rwd template.
Where can I define the cms which is used for the homepage?
I have tried to change the cms.xml
<reference name="content">
<block type="core/template" name="default_home_page" template="cms/default/homeown.phtml"/>
</reference>
and created the cms page homeown
please add your code under <cms_index_index> tag
<cms_index_index>
<reference name="content">
<block type="core/template" name="default_home_page" template="cms/default/homeown.phtml"/>
</reference>
</cms_index_index>

Hide discount code section in cart

I am writing a Magento Extension that is trying to hide the Discount Code section on the checkout cart page. I wrote the following code to replace the current cart.phtml with my custom template.
<layout version="0.1.0">
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setTemplate">
<template>company/module/cart.phtml</template>
</action>
</reference>
</checkout_cart_index>
</layout>
Everything looked good until I realized it even overwrote the template the cart page uses for an empty cart. I have tried many combinations for switch the "checkout_cart_index"
name to the reference name but I cannot get it to just replace that template. I further investigated and found in the default layout it sets the cart values here:
<reference name="content">
<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>
I tried again using "SetCartTemplate" but I cannot get it to display yet alone behave as I am intending. Any ideas?
In your layout update
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setCartTemplate"><value>path/to/your/cart.phtml</value></action>
<action method="setEmptyTemplate"><value>path/to/your/noItems.phtml</value></action>
<action method="chooseTemplate"/>
</reference>
</checkout_cart_index>
chooseTemplate will choose the right template
Try to Rewrite this core class to hide the discount code section in your cart page
Mage_Sales_Model_Quote_Address_Total_Discount

Add a static block to one page checkout in Magento via local.xml

I would like to add a CMS static block (basket_shipping_message) just above the available shipping methods in my Magento checkout. I can edit the phtml file but would rather do it via my local.xml file.
The following code doesen't seem to be working, any ideas?
<checkout_onepage_index>
<reference name="content">
<reference name="shipping_method">
<block type="cms/block" name="basket_shipping_message" before="available">
<action method="setBlockId"><block_id>basket_shipping_message</block_id></action>
</block>
</reference>
</reference>
</checkout_onepage_index>
Did you call in your phtml template getChildHtml('basket_shipping_message');? That should do it. Without that magento does not render the block

Resources