Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6169139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:48:21+00:00 2026-05-23T22:48:21+00:00

I used snippet suggested here Load block outside Magento, and apply current template to

  • 0

I used snippet suggested here

Load block outside Magento, and apply current template

to display a block outside Magento.
Here is my code:

Mage::getSingleton('core/session', array('name'=>'frontend'));

$layout = Mage::app()->getLayout();
$layout->getUpdate()
    ->addHandle('default')
    ->load();

$layout->generateXml()
       ->generateBlocks();

$header = $layout->getBlock('header')->toHtml();
echo $header;

The header is printed, but the topLinks are different from those displayed in Magento.
Even more, the html is slightly different (some divs are missing).
This is my XML layout:

<block type="page/html_header" name="header" as="header">
    <block type="core/text_list" name="top.menu" as="topMenu" translate="label">
        <label>Navigation Bar</label>
    </block>
    <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
    <block type="page/template_links" name="top.links" as="topLinks"/>
    <block type="page/html_wrapper" name="top.bar" as="topBar" translate="label">
        <label>Breadcrumbs</label>
        <action method="setElementClass"><value>top-bar</value></action>
        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
    </block>
    <block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
        <label>Page Header</label>
        <action method="setElementClass"><value>top-container</value></action>
    </block>
</block>

What’s wrong?

UPDATE

Thanks to Alan Storm’s suggestion, now I know the error is not setting correct handles.
I need to add customer_logged_in or customer_logged_out to $layout.
I’ve tried with

Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));

$login_status = '';
if($session->isLoggedIn()){
    $login_status = 'customer_logged_in';
} else {
    $login_status = 'customer_logged_out';
} 

But my user results always logged out even when it’s logged in.
What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:48:22+00:00Added an answer on May 23, 2026 at 10:48 pm

    For starters, you’ve only loaded a single layout handle. Besides the default handle, every Magento page request loads a handle for the store (such as STORE_english ) and a handle indicating if the customer is logged in or out (such as customer_logged_out). Without these handles, certain things don’t happen, and the final rendered page is going to look different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used following code snippet for my activity in order to deal with orientation
This code snippet used to work. I think a recent update of Google Chrome
Code snippet used to allocate cache memory: private static Cache cache = CacheManager.getInstance().getCache(CACHE_NAME); public
I used developerfusion.com to convert a snippet of my C# code to VB .NET
Can anyone share some code snippet used to convert Speech to text in Java.
I once used a code snippet I saw/found in the past that would turn
I used this code snippet to export data to Excel using Open XML. The
I've used the this reference to display the line graph By above code, graph
I have found a code snippet as given below which is used to disable
In the code snippet included below, I have a recursive function call, used to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.