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

  • Home
  • SEARCH
  • 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 3337874
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:18:20+00:00 2026-05-18T00:18:20+00:00

I am trying to create a dynamic sidebar in zend framework. I have googled

  • 0

I am trying to create a dynamic sidebar in zend framework. I have googled some articles, browsed even the stackoverflow archive but i can’t seem to get it so please help me figure this out.
Here is some code from my layout.phtml file:

<div id="contentWrapper">
<div id="contentArea">
<?php echo $this->layout()->content;
?>
</div>
<div id="sidebar">
    <div id="user-authentication">
        <?php if (Zend_Auth::getInstance()->hasIdentity()) {
        ?>Logged In as<br />
        <?php
            echo Zend_Auth::getInstance()->getIdentity();
        } else {
        ?>

            <input type="text" name="login" class="loginInput" /><br/>    
            <input type="password" name="password" class="loginInput" /><br/>    

            <input type="submit" name="submit" value="Log In" class="loginButton" />    
<?php } ?>
    </div>
    <div id="sidebar-content">
                            <? echo $this->layout()->sidebar; ?>
    </div>
</div>

</div>

I could use this Best practice creating dynamic sidebar with zend framework but that means I would need to have redundant code for displaying the login box/logged in as.

  • 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-18T00:18:21+00:00Added an answer on May 18, 2026 at 12:18 am

    Are you just worried about the repetition of hasIdentity and getIdentity in the sidebar-content div?

    If so, maybe you’d prefer this:

    <?php
        $auth = Zend_Auth::getInstance();
        $user = $auth->hasIdentity() ? $auth->getIdentity : NULL;
    ?>
    <div id="user-authentication">
        <?php if ($user) { ?>
            User stuff.
        <?php } else { ?>
            Public stuff.
        <?php } ?>
    </div>
    <div id="user-authentication">
        <?php if ($user) { ?>
            User stuff.
        <?php } else { ?>
            Public stuff.
        <?php } ?>
    </div>
    

    However, that’s just a matter of coding style. There’s nothing wrong with checking a users logged in state more than once. It’s necessary with modular code to do so; that’s probably why Zend_Auth is a Singleton.

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

Sidebar

Related Questions

I'm trying to create a linq query based on some dynamic/optional arguments passed into
I'm trying to create dynamic balls by using a for loop. For some reason
I'm trying to create some dynamic scrollbars for a project I'm working on in
I am trying to create a dynamic table using php but needed to get
I'm trying to create some dynamic code within clojure. In the function below, the
I'm trying to create a dynamic popup window that is able to be re-sized.
I am trying to create a new contact using Dynamic Entity. The sample i
Trying to create a user account in a test. But getting a Object reference
Trying to create a list to return some JSON data to a view. Following
I am trying to create a bunch of dynamic helper methods like these: show_admin_sidebar

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.