paulwallas
Member
Posted 1 year ago #
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?
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?
paulwallas
Member
Posted 1 year ago #
Yeah i have closed these off, i just didn not include them on the post. I will give this a try, thanks
paulwallas
Member
Posted 1 year ago #
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