Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change texts dynamically


cyberjorge

Recommended Posts

Posted

I have static texts on the header.php of my site, that says "Login", this can be clicked and direct the user to the login page.

 

I want this "Login" text to change to "Logout" (also change link to logout.php) upon successful user login.

And also display a text that says "Welcome John" beside the "Login" text that of course hides after logout.

I also want it to be multilingual.

 

Can anyone help me how can this be done?

Thanks in advance!

Posted

Here is the code you need to use

 

<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>

 

It should be multilingual.

If not lt me know i will change the code

In catalog / includes / header.php

find around line 64

 

<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>

 

replace it all with the code at the top.

 

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted

Hi Nic,

 

As expected can't find that code anymore. Maybe because of the totally modified header.php

 

I PM'ed you the link to my site, below is the code for the HTML table that holds the Login button.

 

<table cellspacing=0 cellpadding=0 align=center width=155>			   
 <tr><td width="48" rowspan="2" align=center><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m03.gif width=33 height=33 border=0></a></td>
 <td width="14" height="1" rowspan="2"></td>
 <td width="86" class=cy>Shoping Cart</td></tr>
 <tr><td>now in your cart<b> <br /><a href=<?=tep_href_link('shopping_cart.php')?> class=ml><?=$cart->count_contents()?> items</a></b></td></tr>
 <tr><td height=3 colspan=2></td></tr>
 <tr><td height=8 colspan=3 style="text-align:right"><a href="<?=tep_href_link('login.php')?>" class="ml1">Login / Register </a></td></tr>
</table>

Posted

Yes sorry did think the links were still text based. That code will not be of any use to you.

There may be a contribution for this of try a search of the froum, someone must have wanted this in the past

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted

Thanks for the reply Nic,

 

Yes it is still text. I've been searching this in the forums & contrib section but can't find any.

 

Maybe I provided wrong keywords, I've used: "change text", "dynamic text" and others but returns not related results.

Posted

In your header.php file use this:

 

<table cellspacing=0 cellpadding=0 align=center width=155>			  
 <tr><td width="48" rowspan="2" align=center><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m03.gif width=33 height=33 border=0></a></td>
 <td width="14" height="1" rowspan="2"></td>
 <td width="86" class=cy>Shoping Cart</td></tr>
 <tr><td>now in your cart<b> <br /><a href=<?=tep_href_link('shopping_cart.php')?> class=ml><?=$cart->count_contents()?> items</a></b></td></tr>
 <tr><td height=3 colspan=2></td></tr>
 <tr><td height=8 colspan=3 style="text-align:right"><?php
if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) {
	echo sprintf(TEXT_HEADER_WELCOME, tep_output_string_protected($customer_first_name), tep_href_link('logout.php'));
} else {
	echo '<a href="' . tep_href_link('login.php') . '" class="ml1">' . TEXT_HEADER_LOGIN . '</a>';
}
?></td></tr>
</table>

And in each of your main language files (eg. 'includes/languages/english.php') place the following:

 

// Welcome Header Text
define('TEXT_HEADER_WELCOME', 'Welcome back, %s! <a href="%s" class="ml1">Logout</a>');
define('TEXT_HEADER_LOGIN', 'Login');

Posted

Wow! :D

 

This really helped me! Thanks, thanks, thanks, thanks , thanks a lot KANIE-ADAM!

Wow you really saved my day! It works perfect.

 

For the sake of those reading here, I just changed link from "logout.php" to "logoff.php" and it worked more than perfect!

 

Thanks a lot again, also to Nic. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...