2

I would like to create two store views. One store view that has no header and footer (I want to use this one for my mobile apps). Another store view that has header and footer (I want to use this store view for my existing e-commerce website).

  • are you useing same design package??? – Amit Bera Aug 18 '14 at 16:48
1

Step1:First of all create module control file Module name as Amit_Custommodule.xml at app/etc/modules/. - See more at: http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/#sthash.nuncYnVE.dpuf

<?xml version="1.0"?>
<config>
    <modules>
        <Amit_Custommodule>
            <codePool>community</codePool>
            <active>true</active>
        </Amit_Custommodule>
    </modules>
</config>

Step2: config.xml is app/code/community/Amit/Custommodule/etc/ and code is

Edit: Change event to controller_action_layout_load_before

<?xml version="1.0" ?>
<config>
    <modules>
        <Amit_Custommodule>
            <version>1.0.0</version>
        </Amit_Custommodule>
    </modules>
    <global>
        <models>
            <custommodule>
                <class>Amit_Custommodule_Model</class>
            </custommodule>
        </models>
    </global>
<frontend>
<events>
    <controller_action_layout_load_before>
            <observers> 
            <myredirect>
                <class>custommodule/observer</class>
                <method>myremove</method>
            </myredirect>
        </observers>
    </controller_action_layout_load_before>
 </events>
</frontend>
</config>

and observer code is

   <?php
    class Amit_Custommodule_Model_Observer
    {
    public function myremove($observer)
        {
            try{
                $storeCode = Mage::app()->getStore()->getCode();
if($storeCode=='mobilestorecode'){
                   $blockName = 'footer'; // Add yours
                    $update = Mage::app()->getLayout()->getUpdate();
                    $removeInstruction = "<remove name=\"$blockName\"/>";
                  $update->addUpdate($removeInstruction);
}

            }catch(Excpetion $e){
                Mage::log(print_r($e->getMessage(),1),'null','mage32173.log');
            }

            return;

        }
        }

Just use the extension: modified code:

Mage::helper('mobiledetect')->isMobile() ;

edited:

 public function myremove($observer)
    {
        try{
    if(Mage::helper('mobiledetect')->isMobile()){
               $blockName = 'footer'; // Add yours
                $update = $observer->getEvent()->getLayout()->getUpdate();
                $removeInstruction = "<remove name=\"$blockName\"/>";
              $update->addUpdate($removeInstruction);
    }

        }catch(Excpetion $e){
            Mage::log(print_r($e->getMessage(),1),'null','mage32173.log');
        }

        return;

    }
  • Hi, Dear Amit Bera, it hides header and footer when I call the url www.example.com/?___store=mobile with my browser. When I call the url www.example.com/?___store=mobile with my browser, it also effects to other pcs and they cannot see header and footer already only if they call www.example.com. – Po Po Naing Aug 19 '14 at 2:41
  • For other website users, if they browse by www.example.com, I want them to see with header and footer. But once I run www.example.com/?___store=mobile with my browser, other website users cannot see header and footer already even when they run by www.example.com. – Po Po Naing Aug 19 '14 at 2:44
  • how have you define current store is mobile and default?? – Amit Bera Aug 19 '14 at 3:59
  • I just follow your code. I just change the statement from if($storeCode=='mobilestorecode') to if($storeCode=='mobile') as 'mobile' store is already existed in my magento. I didn't change any settings in admin panel as well. I just create module and follow your way. But header and footer are hidden in other people browsers once I run www.example.com/?___store=mobile with my browser. – Po Po Naing Aug 19 '14 at 6:25
  • then you need to track current device is mobile or pc and put the code in the conditions.... – Amit Bera Aug 19 '14 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.