2

I would like to extend a community module. The one I am refering to is the Inchoo Facebook Login.

This module has a class called Inchoo_Facebook_Block_Template and one of the classes methods is:

public function getRequiredPermissions()
{
    return json_encode('email,user_birthday');
}

I would like to create a module that "extends" (is that the correct term in Magento?) this class and changes what the above method returns. At the moment I am editing the method directly to accomplish my task and changing the above method to:

public function getRequiredPermissions()
{
    return json_encode('email,user_birthday,friends_birthday,user_photos,friends_photos');
}

The module I am creating should add extra Facebook permissions to the Facebook Login module but not edit its contents.

Any help is appreciated.

3

After adding a dependency your etc/modules/*.xml file

<depends>
    <Inchoo_Facebook/>
</depends>

You should be able to safely rewrite the class from your own module:

config.xml

<config>
    <global>
        <blocks>
        <extension>
                <class>Your_Extension_Block</class>
        </extension>
            <inchoo>
                <rewrite>
                    <template>Your_Extension_Block_Template</template>
                </rewrite>
            </inchoo>
        </blocks>
    </global>
</config>

Your/Extension/Block/Template.php

class Your_Extension_Block_Template extends Inchoo_Facebook_Block_Template 
{
    public function getRequiredPermissions()
    {
        return json_encode('email,user_birthday,friends_birthday,user_photos,friends_photos');
    }
}
| improve this answer | |
  • I just had to change the <inchoo> elements to <facebook> and this worked great. Thanks. – beingalex Sep 14 '13 at 14:27
1

Sander's answer will put you on the right track if you want to keep your improvements to yourself. However since we all love open source I suggest you send the guys at Inchoo a pull request with your changes. If you make it optional through a new setting I am fairly sure they would include it.

You can find the code for the Facebook extension on Github.

Also take a look at the Social Connect extension from them which combines the Facebook extension with a range of other login options (currently Google and Twitter).

| improve this answer | |
  • Here is another module that offers twitter, Yahoo and Gmail along with the Facebook login option. fmeaddons.com/magento/… – user9468 Nov 17 '14 at 6:46

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.