• Resolved paulwallas

    (@paulwallas)


    Hi

    I am looking to display a <?php within a <?php echo in order to display the sidebar login for those who are not logged in.

    I am currently using:
    ` if ( is_user_logged_in() ) {
    echo (‘<div id=”topBanner”></div>’);
    } else {
    echo (‘<div id=”panel”>
    <div id=”panel_contents”> </div>
    <div class=”innerContainer clearfix”>
    <h1>Login to the customer area using the fields below:</h1> <?php sidebarlogin(); ?>’)] }; ?>

    .. to display the login form if the user is not logged in however the html displays but the login form does not.

    How do I successfully display the sidebar within the echo?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    try:

    if ( is_user_logged_in() ) {
    echo ('<div id="topBanner"></div>');
    } else {
    echo ('<div id="panel">
    <div id="panel_contents"> </div>
    <div class="innerContainer clearfix">
    <h1>Login to the customer area using the fields below:</h1>'); sidebarlogin(); }; ?>

    btw:
    there are a lot of opened divs in the ‘else’ part of the code; have you taken care to close these divs later?

    Thread Starter paulwallas

    (@paulwallas)

    Yeah i have closed these off, i just didn not include them on the post. I will give this a try, thanks

    Thread Starter paulwallas

    (@paulwallas)

    It works, final code is below:

    if ( is_user_logged_in() ) {
    			echo ('<div id="topBanner"></div>');
    			} else {
    			echo ('<div id="panel">
    						<div id="panel_contents"> </div>
    							<div class="innerContainer clearfix">
    							<h1>Login to the customer area using the fields below:</h1>'); sidebarlogin(); echo ('</div>
    					</div>
    					<div class="innerContainer clearfix">
    						<div class="panel_button"><a href="#">Customer Area</a></div>
    						<div style="display: none;" id="hide_button" class="panel_button"><a href="#">Close this box</a></div>
    					</div>
    				  </div>'); }; ?>

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying php code within php echo’ is closed to new replies.