magento custom CMS page add javascript - php

i am following this howto to add a custom CMS page http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/0_-_theming_in_magento/adding_cms_layout_templates
the issue i am having is that i want to add a NivoSlider javascript just to this page and the only way to add it to the is to do it through the Admin -> CMS -> Pages and then change the Layout Update XML by adding the
<reference name="head">
<action method="addJs">
<script>nivo-slider/jquery.nivo.slider.js</script>
</action>
<action method="addCss">
<script>css/nivo-slider.css
</script></action>
</reference>
is there a way to add the javascript on the filesystem rather then through the Admin -> CMS -> Pages -> Page -> Layout Update XML interface?
any advise much appreciated

You can override page.xml in your layouts folder of your theme and add the script globally like,
<action method="addJs"><script>nivo-slider/jquery.nivo.slider.js</script></action>

You can just write the code directly to your CMS page in the backend as you would write it normally. You can just use <style></style> and/or <script></script> tags and write your CMS site specific code into it.

Related

Location of head in Magento

I am trying to modify the head of my website made in the Magento platform and I am having very much trouble in dooing this. Everywhere I search I read something about app/design/frontend/default/modern/template/page/html/head.phtml
What is this? The physical location of the code ? I only have access to the Magento platform. Is there any way to have acces to the head file? I want to add a metadata (<meta name="google-site-verification" content="quuawwomLqURQt6N34_Pr0cBlYnWcYdiRz8tdXC3Oe8" />) in it and I tried to overwrite the XML file and failed.
I tried something like this:
default>
<reference name="head">
<block type="cms/block" name="google verification" as="google verification">
<action method="setBlockId"><block_id>google_plus</block_id></action>
</block>
</reference>
</default>
If you want to add a custom meta tag to your Magento store, you need to edit the head.phtml file of your current running template.
app/design/frontend/Your-template/default/template/page/html/head.phtml
If you not found this file in your template then you can get this file in
app/design/frontend/base/default/template/page/html/head.phtml
Edit head.phtml file and flush magento cache. Refresh the page and check the source code of page.
In case if you want to add meta title and description data for specific product page then you can check the Link.
To check which template is running currently on your site.
Login into admin panel.
System > configuration > under the left menu find General tab and under this you will get Design tab . Click on Design tab.
Current Package Name is the current template name.
OR To solve your problem (easier):
Use the field Miscellaneous Scripts from System->Configuration->Design->Head and put your scripts in there.
They will be added before the </head> tag and you can set different scripts per website or even store views.

Magento Cart Template Update Not work when first visit a page

I want to override the exist cart template since I add some module in it. I use the XML below to update the layout.
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setCartTemplate">
<value>magefd/shipandpay/checkout/cart.phtml</value>
</action>
<action method="setEmptyTemplate">
<value>checkout/cart/noItems.phtml</value>
</action>
<action method="chooseTemplate"/>
<block type="fdshipandpay/checkout_cart_fee" name="magefd.shipandpay.cart.fee"
as="fee" template="magefd/shipandpay/checkout/cart/fee.phtml" />
</reference>
</checkout_cart_index>
However, the original template will be used when a new user visit the cart at first time. After they refresh, it work perfect. After session time out if the user refresh it, the same problem comes out. I don't know how it happened. Any one can help?
Just copy your .phtml file to all templates directories..eg, Default, and Base theme..Clean cache and try again..

Making a new page template for a different product page

I've been trying to figure this problem out for several hours now - I've made two page templates for the products one is named vxs-view.phtml and the other is view.phtml. There located in the same directory.
The solution I tried was to input
<reference name="product.info">
<action method="setTemplate"> <template>catalog/product/view/vxs-view.phtml</template></action>
</reference>
However this only works if that product is in a certain category. Is there a way I can add the pay layout to the template files in the design tab?
I've been adding this code to the front end system/custom design/ custom layout update box
Sorry I'm need to magento and still learning.
Thanks for any help
you are placing wrong reference type. Please try below code.
<module_page_action> <!- Enter your modulename_pagename_action e.g. catalog_product_info-->
<reference name="root">
<action method="setTemplate"> <template>catalog/product/view/vxs-view.phtml</template></action>
</reference>
<module_page_action>
Hope this will work for you!
Cheers!

Magento List Layout XML

I am trying to get my module to replace the 'media' section on list and grid view on category list pages with my own new one, if there is a hole in Mage knowledge its the layout xml so if someone could help :-) I am using,
<layout>
<catalog_category_view>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/imageover.js</name></action>
</reference>
<reference name="product_list">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="lewis/imageover/media.phtml"/>
</reference>
</catalog_category_view>
</layout>
but it's not working? :s debug toolbar shows my layout is being called but the changed aren't being made.
Edit: Ok with some help from the post below I got it to read my layout, but turns out on the category_list page Magento doesn't use media template the image call is made in the list.phtml file, so the only way to change it appears to be to replace that whole template file. (which seems very extreme!) is there another way to replace the image on the category list page?
What you've done here is effectively reinstantiate the media block with your template. If your changes are solely template-based, you can just <reference name="product.info.media"> the existing block instance from the layout and call <action method="setTemplate"><template>lewis/imageover/media.phtml</...>. If you have your module has a custom block class, you'll need to use your module's block class group. For more on class group notation, the factory method, etc, see Alan Storm's article on the Magento config.

magento custom layout update

Does anybody know how I can call a stylesheet from my skin folder rather than it trying to point to my base path? I currently have
<reference name="head">
<action method="addCss">
<stylesheet>yourtheme/css/red.css</stylesheet>
<params>media="screen"</params>
</action>
</reference>
It's ok I'm cracking up, it's cause the css file wasn't in my skin folder - I was just looking at the view source, obviously if it doesn't find the file it defaults to the base path- doh!

Categories