Magento Forum

How do I integrate my own module to set coockies for different websites and remember? 
 
davidgrun
Sr. Member
 
Total Posts:  245
Joined:  2008-07-10
 

Hello!
I have a small PHP and JS code that checks and sets some coockies as soon as a new visitor comes to our website. These coockies determine which website to direct the visitor to
http://www.domain.com
or
http://www.domain.com/international

As soon as a visitor comes for first time a dialog box appears and asks him if he is from Argentina or International. When he clicks on one choice it sets the coockie and continues.

So next time the visitor comes it will remember to which website to direct him.

Now the catch is that say a visitor goes to http://www.domain.com, clicks on ‘International’, sets the coockie ‘int’ and redirects him to http://www.domain.com/international
next time he saw a link to a promotion, http://www.domain.com/the-promotion — based on the coockie, the website should redirect him to http://www.domain.com/international/the-promotion.

So this script will check what coockie is set, if needed add ‘/international’, and redirect to the final location.

So based on this tutorial I thought I need to do this as a module and place the block code on the app/design/........./layout/page.xml

but, ofcourse since I’m not sure of what I’m doing I get the following error:
Fatal error: Call to a member function toHtml() on a non-object in C:\AppServ\www\app\code\core\Mage\Core\Block\Abstract.php on line 503

Here is my code:
app/etc/modules/Residente.xml

<?xml version="1.0"?>
<config>
  <
modules>
    <
Residente_Custom>
      <
active>true</active>
      <
codePool>local</codePool>
    </
Residente_Custom>
  </
modules>
</
config>

app/code/local/Residente/Custom/etc/config.xml

<?xml version="1.0"?>
<config>
  <global>
    <
blocks>
      <
residente_custom>
        <class>
Residente_Custom_Block</class>
      </
residente_custom>
    </
blocks>
  </global>
</
config>

app/code/local/residente/custom/block/Coockies.php

file is too largelook in attached file

app/design/........./layout/page.xml

<default>
      <
block>
...
...
            <!-- 
LIGHTBOX Coockies Module #Custom -->
                
<block type="residente_custom/coockies"/>
            <!-- 
// LIGHTBOX Coockies Module -->
            
</block>
...
</default>

I’d really appreciate your help!! And perhaps someone might benefir (although something tells me I’m reinventing the wheel)

THANK You for your help!!
David

File Attachments
coockies-MagentoForum.zip  (File Size: 7KB - Downloads: 32)
 
Magento Community Magento Community
Magento Community
Magento Community
 
davidgrun
Sr. Member
 
Total Posts:  245
Joined:  2008-07-10
 

Is there anyone here that can please help?!?!?!
Thanks
David

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top