1

Hereby, I working to integrating Header/Footer section outside Magento using this sample code:

$mageFilename = 'app/Mage.php';
echo $mageFilename;
require_once $mageFilename;
#Mage::setIsDeveloperMode(true);
#ini_set('display_errors', 1);
umask(0);
Mage::app()->loadArea('frontend');

$layout = Mage::getSingleton('core/layout');

//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();

//get the loaded head and header blocks and output
$headBlock = $layout->getBlock('head');
$headerBlock = $layout->getBlock('header');
echo $headBlock->toHtml() . $headerBlock->toHtml();..


reset of your code

When i get all header/footer content include site Logo and etc.But it doesn't get Login and Logout from that Header section. Here i Sample Headers

DEMO Outside Magento
and sample Header for Magento Website DEMO Magento
How to call Login And logout detail outside magento.Kindly advise me any other issues?

2
  • You say you are building your site 'outside' of Magento? Is the site in some other CMS that you want to interact with Magento? Commented Feb 17, 2015 at 20:55
  • Yes @JasonTipton..I am interact with core php file with magento.How to achieve outside magento with same header and footer..I get header without login links.How to get Header without login details?
    – VIVEK-MDU
    Commented Feb 18, 2015 at 5:56

2 Answers 2

2

Links to add Login and Logout links are in the <customer_logged_in> and <customer_logged_out> handles, respectively.

Add them to your script with the following code:

if( Mage::helper('customer')->isLoggedIn() ) {
    $layout->getUpdate()->addHandle('customer_logged_in');
} else {
    $layout->getUpdate()->addHandle('customer_logged_out');
}
2
  • i executed your code into my custom page.No response any other change can taken in magento?Kindly advise me..How to achieve login and logout outside magento?
    – VIVEK-MDU
    Commented Feb 18, 2015 at 5:57
  • Use $this->getLayout()->getNode()->asNiceXml() to see what layout instructions are currently being loaded. See if the the appropriate handles and blocks are in the layout. Commented Feb 19, 2015 at 5:59
3

First check if user logged in or not then add log in/log out to your header :
use the following code:

if(Mage::getSingleton('customer/session')->isLoggedIn()){
   $layout->getUpdate()->addHandle('customer_logged_in');
}else{
   $layout->getUpdate()->addHandle('customer_logged_out');
}
1
  • please put some details thus anyone can understand the code
    – Amit Bera
    Commented May 28, 2015 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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