Monthly Archives: January 2009

  • magento top links

    Magento Support - Add, Edit and Remove Magento Top Links

    This is a simple trick, and often requested for Magento support. The general rule for each Magento top link is that each is mostly controlled by the Magento layout,  so check layout/module_name.xml first.

    To Add a new top link:
    Sample code:

        <reference name="top.links">
            <action method="addLink" translate="label title" module="module_name">
                <label>My Top Link Name</label>
                <url helper="module_name/get_top_link_target_url"/>
                <title>My Top Link Title</title>

    Continue reading

  • Magento form validation using Varien JavaScript objects

    When building new pages in Magento, form validation is usually a necessary but highly repetitive process.

    Luckily, Magento already comes with very nice form validation functions written in JavaScript.

    Here is a quick demo of how to use it, based on the Magento customer login form.

    At the end of the .phtml template file, attach the following code:

    <script type="text/javascript">
        var loginForm = new VarienForm('login-form', true);
        $('login-email').observe('keypress', bindLoginPost);
        $('login-password').observe('keypress', bindLoginPost);
        function bindLoginPost(evt){
            if (evt.keyCode == Event.KEY_RETURN) {
        function onepageLogin(button){
            if(loginForm.validator &&  loginForm.validator.validate()){
                button.disabled = true;

    The key is to wrap a VarienForm object around our form element with id='login-form', and then loginForm.validator.validate() will handle everything with ease.

    Continue reading

2 Item(s)

Back to top