Guest Posted July 29, 2006 Share Posted July 29, 2006 Could someone please help me? In includes>header.php the following code allows for a menu item to appear only if the customer is logged in. <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_EXAMPLE, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> <?php } ?> The following code will allow that same link to appear regardless of whether the customer is logged in or not. <a href="<?php echo tep_href_link(FILENAME_EXAMPLE); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> So far, fairly straight forward But what I am trying to do is create an either/or scenario If the client is not logged in, the example link will appear, but once logged in, that link will disappear to make room for the logged in only links. Am I explaining myself ok? Can anyone assist please? I do hope so, as the ability to do this would solve a myriad of design problems for me. Link to comment Share on other sites More sharing options...
dittones Posted July 29, 2006 Share Posted July 29, 2006 Dear Grandma, Could you have what you want by adding an else condition...as such. Roman Link to comment Share on other sites More sharing options...
jhande Posted July 29, 2006 Share Posted July 29, 2006 Jim, this might sound silly (I don't know much at all about php) but what if you combine both codes? Something like this - <a href="<?php echo tep_href_link(FILENAME_EXAMPLE); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> <?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_EXAMPLE, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> <?php } ?> Then possibly the top menu would show when the customer is not logged in and the bottom menu might show when the customer is logged in? Don't laugh too hard, like I said... I don't have a clue regarding PHP! :blush: - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 - Link to comment Share on other sites More sharing options...
Guest Posted July 29, 2006 Share Posted July 29, 2006 Roman Yes...from what I can understand of php, that would work, but from my searches so far, I can't seem to get the syntax right. That's what I need help with. Basically I'm looking for correct way to say... If not logged in, show this link. ELSE, show nothing. (Or blank) But for this one link only. There are of course already links there that show only if the customer is logged in. Sort of the reverse. Log-off, My Account etc etc If logged in, show this link. There seems to be no need for an "else" statement That's what led me to think there may be a way of saying... If not logged in ...show this link. But it then shows up when logged in as well, which is not what I want. Jim "Playing around" and experienting with modifying the code has taken me a long way over the past year, so I'm certainly not about to laugh at your suggestion. Unfortunately, what you've suggested would show the first link all the time. Logged in or not. The second snippet would add the link if logged in. Therefore we would be having two links if logged in. Not what I'm after. Thanks for your interest anyway Link to comment Share on other sites More sharing options...
Guest Posted July 29, 2006 Share Posted July 29, 2006 Just to add. I have actually tried a combination of the two suggestions made so far before coming here. <?php if (tep_session_is_registered('customer_id')) { <?php echo .; ?> <?php } ?> } else { <a href="<?php echo tep_href_link(FILENAME_EXAMPLE); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> Trying to make just a full stop appear if logged in. Didn't work. Link to comment Share on other sites More sharing options...
Maggilove Posted July 29, 2006 Share Posted July 29, 2006 If you want a link to show only when a customer is not logged in, just add an exclamation mark to your first code example, like this... <?php if (!tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_EXAMPLE, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_EXAMPLE; ?></a> <?php } ?> Link to comment Share on other sites More sharing options...
Guest Posted July 29, 2006 Share Posted July 29, 2006 My goodness! Is that all it takes? I'm amazed....and grateful. Assuming "Maggi" is a lady...you're an angel. Thank you. (If "Maggi" happens to be a bloke, like "Granma"....Thanks mate!) Link to comment Share on other sites More sharing options...
Guest Posted July 29, 2006 Share Posted July 29, 2006 Maggi is all gal! *grins* She's amazing, ain't she? She's helped me A LOT! Glad you got your situation settled! Can't wait to see the finished product! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.