dave47 Posted August 26, 2008 Posted August 26, 2008 Hi, Ive made a navigation bar with a login button in my header image. You can see the site here. I'd like to know how to incorporate the login/logout button, to change image when clicked on. To my way of thinking, Id have to make two buttons, one with the login text, and another for the logout text. I dont know if that correct? Secondly, what code would I have to add or change to get it working? Thank you in advance
Daemonj Posted August 26, 2008 Posted August 26, 2008 You would indeed need to have 2 buttons. Then you would need an if statement that checks if the current user is logged in or not. If they are, display the logout button and if they are not then display the login button. You can look in the includes/header.php file for an example. "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
dave47 Posted August 26, 2008 Author Posted August 26, 2008 You would indeed need to have 2 buttons. Then you would need an if statement that checks if the current user is logged in or not. If they are, display the logout button and if they are not then display the login button. You can look in the includes/header.php file for an example. Thanks for the quick reply. Do you mean this bit of code? <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> | <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a> <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a> | <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a> </td> If it is, what part of it looks for the checks? Im asking, as Im not a php techie.
FIMBLE Posted August 26, 2008 Posted August 26, 2008 I wrote this a while back, it starts as a log in text then changes to log off once a customer logs in, you can alter it for your needs no worries Nic <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { } else {echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '"class="headerNavigation">' . HEADER_TITLE_LOGIN . '</a> ';} ?> <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a> <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a> <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a></td> Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Daemonj Posted August 27, 2008 Posted August 27, 2008 @dave47, you are correct. Specifically this piece of code within the block you showed: <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> | <?php } ?> "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
dave47 Posted August 27, 2008 Author Posted August 27, 2008 I wrote this a while back, it starts as a log in text then changes to log off once a customer logs in, you can alter it for your needs no worriesNic <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { } else {echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '"class="headerNavigation">' . HEADER_TITLE_LOGIN . '</a> ';} ?> <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a> <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a> <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a></td> Sorry to be a pain, but that just adds the same code into the breadcrumbs. I need to put it in my header pic. If you have a look at my site, you'll see where I want it. Thanks. Also what part of the code relates to login/logout? I dont want the "My Account or Shopping cart code, as Ive already got a link to them.
FIMBLE Posted August 27, 2008 Posted August 27, 2008 <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { } else {echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '"class="headerNavigation">' . HEADER_TITLE_LOGIN . '</a> ';} ?> <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> That is the code for the login and log off, all you need do is rearrange to suit your need, add the images in there. replace the HEADER_TITLE_LOGIN & FILENAME_LOGOFF with your images (may need a bit of jerking around), leave the SSL there or your customers will be unprotected. Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
dave47 Posted August 27, 2008 Author Posted August 27, 2008 <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { } else {echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '"class="headerNavigation">' . HEADER_TITLE_LOGIN . '</a> ';} ?> <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a> That is the code for the login and log off, all you need do is rearrange to suit your need, add the images in there. replace the HEADER_TITLE_LOGIN & FILENAME_LOGOFF with your images (may need a bit of jerking around), leave the SSL there or your customers will be unprotected. Thanks for your help guys, I'll give it try.
dave47 Posted August 27, 2008 Author Posted August 27, 2008 Thanks for your help guys, I'll give it try. Hmmm, Ive tried the mod but each time Ive added the images I'm getting a parse error with a blank screen. I added the images to replace <?php echo HEADER_TITLE_LOGOFF; ?> and the HEADER_TITLE_LOGOFF as sugested. I also added the images between the ' ' in this part of the code tep_href_link(FILENAME_LOGIN,[b] ' ',[/b] 'SSL') ..and still got the parse error. So could someone help out as I dont know why Im getting the parse error?
dave47 Posted August 27, 2008 Author Posted August 27, 2008 Hmmm, Ive tried the mod but each time Ive added the images I'm getting a parse error with a blank screen. I added the images to replace <?php echo HEADER_TITLE_LOGOFF; ?> and the HEADER_TITLE_LOGOFF as sugested. I also added the images between the ' ' in this part of the code tep_href_link(FILENAME_LOGIN,[b] ' ',[/b] 'SSL') ..and still got the parse error. So could someone help out as I dont know why Im getting the parse error? Hi Guys, I could still do with your help please?
Daemonj Posted August 27, 2008 Posted August 27, 2008 What are the names of your images? "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
dave47 Posted August 27, 2008 Author Posted August 27, 2008 What are the names of your images? Thanks for replying again, Daemonj, Ive named the images: log_in_btn.png and log_out_btn.png as I used Fireworks to create them. Since youve just asked, Im wondering (probably the same as you), that maybe the file names should be changed? Once Ive got them showing, can I enclose them in a <div> tag and write a new style tag in CSS Stylesheet so I can position them where I want them? Will that work?
Daemonj Posted August 27, 2008 Posted August 27, 2008 Your filenames are not an issue. I just asked for them so I could give you a good code example. I have written the code below in a way that should make it very readable and easy to understand. You could indeed wrap the entire code block in a div tag with a CSS styled id to format as you wish. As a note, the image files need to be placed in your includes/languages/[language]/images/buttons folder. <?php if (tep_session_is_registered('customer_id')) : ?> <a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"> <?php echo tep_image_button('log_out_btn.png'); ?> </a> <?php else: ?> <a href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>" class="headerNavigation"> <?php echo tep_image_button('log_in_btn.png'); ?> </a> <?php endif; ?> "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
dave47 Posted August 27, 2008 Author Posted August 27, 2008 I'd like to say thanks to the guys that have helped me out. I just had a minor problem with the positioning, but thats now sorted.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.