.

.

Call Any block Or Extension in any Page in Magento



Here I am  using my left navigation extension in home Page.
I  call Extension block in Home page layout . For Home Page we  will edit in local.xml .
Firstly Find Out the block where we used & call it any layout where you want
Like Our Extension block is this :-
<block type="sidenav/navigation" name="codnitive.home.sidenav.content.top" as="codnitiveSidenavContent" before="slider">
                <action method="setTemplate" modules="codnitivecatalog/sidenav/">
                    <template>codnitive/sidenav/navigation.phtml</template>
                </action>
            </block>


Now we put this block in Home Page . So we have to change in  local.xml
Suppose this is  home  page layout here we add left navigation in index reference & before content & before slider so call it just like this in xml File .
Themename/default/layout/local.xml

local.xml


<cms_index_index>
        <reference name="root">
<block type="sidenav/navigation" name="codnitive-home-side-nav" as="codnitive-home-side-nav" before="slider" template="codnitive/sidenav/navigation.phtml">            
            </block>                                              
               
            <!-- define the block slider -->
            <block type="cms/block" name="slider" as="slider" translate="label" before="content" after="codnitive-home-side-nav">
                <action method="setBlockId"><block_id>home-carousel</block_id></action>
            </block>                                                 
                                                                            
        </reference>                                        
        <reference name="left">
            <block type="catalog/navigation" before="-" name="leftNav" as="leftNav" template="catalog/navigation/leftnav.phtml"/>
        </reference>
        <reference name="content">
            <block type="cms/block" name="home-slider-below-banner" before="-" after="slider">
               <action method="setBlockId"><block_id>home-block-below-slider</block_id></action>
           </block>                                               
                                                                                               
        </reference>
    </cms_index_index>
Now this  navigation block call in .phtml file . Here For Home Page Cms we call 1 column layout.
So we call it in theme name/template/page/html.1column.phtml 
Like this
<?php
// call codinative slider
//call block name
echo $this->getChildHtml('codnitive-home-side-nav');

?>

Get Blog Post Outsite Wordpress


<?php
   require 'blog/wp-load.php';  
   ?>
<?php
//instantiate a WP_Query and get the latest 10 posts
$wp_query = new \WP_Query();
$wp_query->query('showposts=3');
?>
<?php
//Iterate through the returned posts. The starts the WP "Loop"
while ($wp_query->have_posts()) :
  $wp_query->the_post();
?>
<a href="<?php the_permalink() ?>" target="_blank">
                  <?php the_title(); ?>
                  </a>
<?php if(has_post_thumbnail())
              {?>
<a href="<?php the_permalink() ?>" target="_blank"><img src="<?php echo the_post_thumbnail_url('large'); ?>" style="width:100%;" ></a>
                <?php }?>
<?php //$authorId = the_author_ID();
              
                $args = get_avatar_data(the_author_ID(),'' );
               
      $imgurl= $args['url'];
     
      ?>
                    <img src="<?php echo $imgurl; ?>" style="border-radius:100%;width:80px;height:80px;z-index:999;margin-left:-15px !important;" align="middle">
                    <h3><?php echo ucwords(get_author_name());?></h3>
<?php the_time( get_option( 'date_format' ) ); ?>
  <p> <a href="<?php comments_link(); ?>">
    Leave a Comment
</a></p>

Facebook Login in magento programattically

<?php
//header("Content-Type: application/json");
require_once 'app/Mage.php';
//facebook
require_once 'app/code/community/Inchoo/SocialConnect/controllers/FacebookController.php';
require_once 'app/code/community/Inchoo/SocialConnect/Helper/Facebook.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Facebook/Client.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Facebook/Userinfo.php';

Mage::app('default');  
Mage::getSingleton("core/session", array("name" => "frontend"));
$data=array();

if($_REQUEST['facebookId']=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Facebook Id';
    echo json_encode($data);
return;
}
else
{
    $facebookId=$_REQUEST['facebookId'];  
}

if($_REQUEST['firstName']=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter FirstName';
    echo json_encode($data);
return;
    }
else
{
$firstName=$_REQUEST['firstName'];  
}

if($_REQUEST['lastName']=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter LastName';
    echo json_encode($data);
return;
    }
    else
    {
      
$lastName=$_REQUEST['lastName'];          
        }


if($_REQUEST['email']=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Email';
    echo json_encode($data);
return;
    }
    else
    {
        $email=$_REQUEST['email'];
      
        }


if($_REQUEST['token']=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Token';
    echo json_encode($data);
return;
}
else
{
    $token=$_REQUEST['token'];
}

if($firstName!='' && $lastName!='' && $email!=''  && $facebookId!='')
{
    // start here facebook code
  
               // Facebook API green light - proceed
            $client = Mage::getSingleton('inchoo_socialconnect/facebook_client');

          
          //$token = $client->getAccessToken();
          $token=$token;

            $customersByFacebookId = Mage::helper('inchoo_socialconnect/facebook')->getCustomersByFacebookId($facebookId);
            //print_r($customersByFacebookId);
      $customersByFacebookId->count();
            if(Mage::getSingleton('customer/session')->isLoggedIn()) {
                // Logged in user
                if($customersByFacebookId->count()) {
                    // Facebook account already connected to other account - deny
                    Mage::getSingleton('core/session')
                        ->addNotice('Your Facebook account is already connected to one of our store accounts.');
                        $data['responseCode']='1';
                        $data['msg']='Your Facebook account is already connected to one of our store accounts';
                        echo json_encode($data);
                    return;
                }

                // Connect from account dashboard - attach
                $customer = Mage::getSingleton('customer/session')->getCustomer();

                Mage::helper('inchoo_socialconnect/facebook')->connectByFacebookId($customer,$facebookId,$token);

                Mage::getSingleton('core/session')->addSuccess('Your Facebook account is now connected to your store accout. You can now login using our Facebook Connect button or using store account credentials you will receive to your email address.');
              
$data['responseCode']='1';
                        $data['msg']='Your Facebook account is now connected to your store accout. You can now login using our Facebook Connect button or using store account credentials you will receive to your email address';

echo json_encode($data);
                return;
            }

            if($customersByFacebookId->count()) {
                // Existing connected user - login
                $customer = $customersByFacebookId->getFirstItem();

                Mage::helper('inchoo_socialconnect/facebook')->loginByCustomer($customer);

                Mage::getSingleton('core/session')
                    ->addSuccess('You have successfully logged in using your Facebook account.');

$data['responseCode']='1';
                        $data['msg']='You have successfully logged in using your Facebook account';

echo json_encode($data);

                return;
            }

            $customersByEmail = Mage::helper('inchoo_socialconnect/facebook')->getCustomersByEmail($email);

            if($customersByEmail->count()) {              
                // Email account already exists - attach, login
                $customer = $customersByEmail->getFirstItem();
              
                Mage::helper('inchoo_socialconnect/facebook')->connectByFacebookId($customer,$facebookId,$token);

                Mage::getSingleton('core/session')->addSuccess('We have discovered you already have an account at our store. Your Facebook account is now connected to your store account.');
                $data['responseCode']='1';
                $data['msg']='We have discovered you already have an account at our store. Your Facebook account is now connected to your store account';
                echo json_encode($data);

                return;
            }

            // New connection - create, attach, login
            if(empty($firstName)) {
                throw new Exception('Sorry, could not retrieve your Facebook first name. Please try again.');
                $data['responseCode']='0';
                $data['msg']='Sorry, could not retrieve your Facebook first name. Please try again';
                echo json_encode($data);
                return;
              
            }

            if(empty($lastName)) {
                throw new Exception('Sorry, could not retrieve your Facebook last name. Please try again.');
                $data['responseCode']='0';
                $data['msg']='Sorry, could not retrieve your Facebook last name. Please try again';
                echo json_encode($data);
                return;
            }

            Mage::helper('inchoo_socialconnect/facebook')->connectByCreatingAccount($email,$firstName,$lastName,$userInfo->id,$token);

            Mage::getSingleton('core/session')->addSuccess('Your Facebook account is now connected to your new user accout at our store. Now you can login using our Facebook Connect button or using store account credentials you will receive to your email address.');
            $data['responseCode']='1';
            $data['msg']='Your Facebook account is now connected to your new user accout at our store. Now you can login using our Facebook Connect button or using store account credentials you will receive to your email address';
            echo json_encode($data);
            return;
//end here facebook code
  
    }
  
    else
    {
        $data['responseCode']='0';
        $data['msg']='Please Enter Appropriate Fields';
        echo json_encode($data);
return;      
        }
  
 ?>

Twitter Login from outside in magento programattically

<?php
require_once 'app/Mage.php';

//twitter
require_once 'app/code/community/Inchoo/SocialConnect/controllers/TwitterController.php';
require_once 'app/code/community/Inchoo/SocialConnect/Helper/Twitter.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Twitter/Client.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Twitter/Userinfo.php';
Mage::app('default');  
Mage::getSingleton("core/session", array("name" => "frontend"));
?>
<?php
$data=array();

//get twitterid

  $twitterid = $_REQUEST['twitId'];
if($twitterid=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Twitter Id';
    echo json_encode($data);
return;
}


// get first name & last name

$fullname= $_REQUEST['fullName'];
//print_r($fullname);
 $fname = $fullname[0];

if($fname=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter FirstName';
    echo json_encode($data);
return;
    }
  
 $lastname = $fullname[1];
if($lastname=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter LastName';
    echo json_encode($data);
return;
    }



// get token
  $token=$_REQUEST['token'];

if($token=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Token';
    echo json_encode($data);
return;
}


//start for email by screen Name
$screen_name=$_REQUEST['screenName'];
  $email = sprintf('%s@twitter-user.com', strtolower($screen_name));

//end for email by screen Name

if($fname!='' && $lastname!=''  && $token!='' && $twitterid!='')
{
    // start here twitter code
  
    //$client = Mage::getSingleton('inchoo_socialconnect/twitter_client');
    //print_r($clientnew);

      //$token = $client->getAccessToken();
      
       /* $userInfo = (object) array_merge(
                (array) ($userInfo = $client->api('/account/verify_credentials.json', 'GET', array('skip_status' => true))),
                array('email' => sprintf('%s@twitter-user.com', strtolower($userInfo->screen_name)))
        );
*/
        $customersByTwitterId = Mage::helper('inchoo_socialconnect/twitter')->getCustomersByTwitterId($twitterid);
      
      

        if(Mage::getSingleton('customer/session')->isLoggedIn()) {          
      
            // Logged in user
            if($customersByTwitterId->count()) {
                // Twitter account already connected to other account - deny
                Mage::getSingleton('core/session')->addNotice('Your Twitter account is already connected to one of our store accounts.');
              
                    $data['responseCode']='1';
                  
                    $data['msg']='Your Twitter account is already connected to one of our store accounts';
                    $data['id']=Mage::getSingleton('core/session')->getCustomer()->getId();
echo json_encode($data);
                return;
            }
            // Connect from account dashboard - attach
            $customer = Mage::getSingleton('customer/session')->getCustomer();
           Mage::helper('inchoo_socialconnect/twitter')->connectByTwitterId($customer,$twitterid,$token);
/*         
 Mage::getSingleton('core/session')->addSuccess('Your Twitter account is now connected to your store accout. You can now login using our Twitter Connect button or using store account credentials you will receive to your email address.');*/
            $data['responseCode']='1';
            $data['msg']='Your Twitter account is now connected to your store accout. You can now login using our Twitter Connect button or using store account credentials you will receive to your email address';
            $data['id']=$customer->getId();          
echo json_encode($data);
            return;
        }

        if($customersByTwitterId->count()) {
            // Existing connected user - login
            $customer = $customersByTwitterId->getFirstItem();

           $twittcustomer = Mage::helper('inchoo_socialconnect/twitter')->loginByCustomer($customer);

            Mage::getSingleton('core/session')->addSuccess('You have successfully logged in using your Twitter account.');
          
            $data['responseCode']='1';
            $data['msg']='You have successfully logged in using your Twitter account';
            $data['id']=$customer->getId();
             echo json_encode($data);          

            return;
        }

        $customersByEmail = Mage::helper('inchoo_socialconnect/twitter')->getCustomersByEmail($email);

        if($customersByEmail->count()) {
            // Email account already exists - attach, login
            $customer = $customersByEmail->getFirstItem();

           $twittcustomer= Mage::helper('inchoo_socialconnect/twitter')->connectByTwitterId($customer,$twitterid,$token);

            Mage::getSingleton('core/session')->addSuccess('We have discovered you already have an account at our store. Your Twitter account is now connected to your store account.');
            $data['responseCode']='1';
            $data['msg']='We have discovered you already have an account at our store. Your Twitter account is now connected to your store account';
            //$data['id']=Mage::getSingleton('core/session')->getCustomer->getId();
            echo json_encode($data);
            return;
        }

        // New connection - create, attach, login
        if(empty($fname)) {
            throw new Exception('Sorry, could not retrieve your Twitter last name. Please try again.');
            $data['responseCode']='0';
            $data['msg']='Sorry, could not retrieve your Twitter last name. Please try again';
            echo json_encode($data);
        }

        Mage::helper('inchoo_socialconnect/twitter')->connectByCreatingAccount($email,$fname,$twitterid,$token);
        Mage::getSingleton('core/session')->addSuccess('Your Twitter account is now connected to your new user accout at our store.');             
        Mage::getSingleton('core/session')->addNotice(sprintf('Since Twitter doesn\'t support third-party access to your email address, we were unable to send you your store accout credentials. To be able to login using store account credentials you will need to update your email address and password using our <a href="%s">Edit Account Information</a>.'), Mage::getUrl('customer/account/edit'));       
        $data['responseCode']='0';
        $data['msg']='Your Twitter account is now connected to your new user accout at our store.Since Twitter doesn\'t support third-party access to your email address, we were unable to send you your store accout credentials. To be able to login using store account credentials you will need to update your email address and password';     
     echo json_encode($data);
          
            return;
  
    //end here twitter code
  
    }
  
    else
    {
        $data['responseCode']='0';
        $data['msg']='Please Enter Appropriate Fields';
        echo json_encode($data);
return;      
        }
  
  
  

 ?>

Google Login from Outside in magento Programattically


I used Inchoo Social Login Extension in Magento For My web Application. And also I need social login webservices For my magento android app. Here I have done webservices for Google login By using Inchoo Social Extension.

<?php
require_once 'app/Mage.php';
require_once 'app/code/community/Inchoo/SocialConnect/controllers/GoogleController.php';
require_once 'app/code/community/Inchoo/SocialConnect/Helper/Google.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Google/Client.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Google/Userinfo.php';

//facebook
require_once 'app/code/community/Inchoo/SocialConnect/controllers/FacebookController.php';
require_once 'app/code/community/Inchoo/SocialConnect/Helper/Facebook.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Facebook/Client.php';
require_once 'app/code/community/Inchoo/SocialConnect/Model/Facebook/Userinfo.php';

Mage::app('default');   
Mage::getSingleton("core/session", array("name" => "frontend"));
$data=array();

$googleid = $_REQUEST['googleid'];
if($googleid=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Google Id';
    echo json_encode($data);
return;
}

// get first name & last name

 $gname=$_REQUEST['fullname'];
//print_r($gname);
 $fullname= explode(' ',$gname);

 $firstname = $fullname[0];
if($firstname=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter FirstName';
    echo json_encode($data);
return;
    }
   
 $lastname = $fullname[1];
if($lastname=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter LastName';
    echo json_encode($data);
return;
    }

//get Email Id
 $email=$_REQUEST['email'];
if($email=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Email';
    echo json_encode($data);
return;
    }

// get token

 $token1=str_replace('.','',$_REQUEST['token']);
$token2=str_replace("'","",$token1);
$token=str_replace(",","",$token2);


if($token=='')
{
    $data['responseCode']='0';
    $data['msg']='Please Enter Token';
    echo json_encode($data);
return;
}

if($firstname!='' && $lastname!='' && $email!='' && $token!='' && $googleid!='')
{
    // start here google code
   
     // Google API green light - proceed
            $client = Mage::getSingleton('inchoo_socialconnect/google_client');

            //$userInfo = $client->api('/userinfo');
            //$token = $client->getAccessToken();
            $token=$token;

            $customersByGoogleId = Mage::helper('inchoo_socialconnect/google')->getCustomersByGoogleId($googleid);

            if(Mage::getSingleton('customer/session')->isLoggedIn()) {
                // Logged in user
                if($customersByGoogleId->count()) {
                    // Google account already connected to other account - deny
                    Mage::getSingleton('core/session')->addNotice('Your Google account is already connected to one of our store accounts.');
                    $data['responseCode']='1';
                    $data['msg']='Your Google account is already connected to one of our store accounts';
echo json_encode($data);
return;
          
                }

                // Connect from account dashboard - attach
                $customer = Mage::getSingleton('customer/session')->getCustomer();

                Mage::helper('inchoo_socialconnect/google')->connectByGoogleId($customer,
                    $googleid,
                    $token
                );

                Mage::getSingleton('core/session')->addSuccess('Your Google account is now connected to your store accout. You can now login using our Google Connect button or using store account credentials you will receive to your email address.');
               
$data['responseCode']='1';
$data['msg']='Your Google account is now connected to your store accout. You can now login using our Google Connect button or using store account credentials you will receive to your email address';

echo json_encode($data);
return;
             
            }

            if($customersByGoogleId->count()) {
               
                // Existing connected user - login
                $customer = $customersByGoogleId->getFirstItem();

                Mage::helper('inchoo_socialconnect/google')->loginByCustomer($customer);

                Mage::getSingleton('core/session')->addSuccess('You have successfully logged in using your Google account.');
                $data['responseCode']='1';
                $data['msg']='You have successfully logged in using your Google account';
echo json_encode($data);
return;               
            }

            $customersByEmail = Mage::helper('inchoo_socialconnect/facebook')
                ->getCustomersByEmail($email);

            if($customersByEmail->count())  {
                // Email account already exists - attach, login
                $customer = $customersByEmail->getFirstItem();
               
                Mage::helper('inchoo_socialconnect/google')->connectByGoogleId(
                    $customer,
                    $googleid,
                    $token
                );

                Mage::getSingleton('core/session')->addSuccess('We have discovered you already have an account at our store. Your Google account is now connected to your store account.');
                $data['responseCode']='1';
                $data['msg']='We have discovered you already have an account at our store. Your Google account is now connected to your store account';
echo json_encode($data);
return;              
            }
                       

            // New connection - create, attach, login
            if(empty($firstname)) {
                throw new Exception('Sorry, could not retrieve your Google first name. Please try again.'
                );
                $data['responseCode']='0';
                $data['msg']='Sorry, could not retrieve your Google first name. Please try again';
                echo json_encode($data);
return;
            }

            if(empty($lastname)) {
                throw new Exception('Sorry, could not retrieve your Google last name. Please try again.'
                );
               
                $data['responseCode']='0';
                $data['msg']='Sorry, could not retrieve your Google last name. Please try again';
                echo json_encode($data);
return;
            }

            Mage::helper('inchoo_socialconnect/google')->connectByCreatingAccount($email,$firstname,$lastname,$googleid,            $token );

            Mage::getSingleton('core/session')->addSuccess('Your Google account is now connected to your new user accout at our store. Now you can login using our Google Connect button or using store account credentials you will receive to your email address.');
   
    $data['responseCode']='1';
    $data['msg']='Your Google account is now connected to your new user accout at our store. Now you can login using our Google Connect button or using store account credentials you will receive to your email address';
   
    echo json_encode($data);
return;
       
    //end here google code   
    }
   
    else
    {
        $data['responseCode']='0';
        $data['msg']='Please Enter Appropriate Fields';
        echo json_encode($data);
return;       
        }

 ?>