chrometweaks.org

Question about Transferring a Domain from iPage?

Click Here To View All Answers...


Got a question, hope someone can answer... Question about Transferring a Domain from iPage? Many thanks for any response. Another quick question... In /catalog/includes/languages/english.php, I see many instances where a variable is called using "%s" one of them being for the login link on index.php..

It appears to echo the relevant variable somehow, but how does it know what to put where? Where is that defined?.

The reason I ask is because I wanted to add a login link to my header.php file, and thought I could pull the code from the index page, but I don't know if that would work in the header as well..

TIA for any help / explanations..

Terry..

Comments (68)

I would like to know the answer too. Anyone here know what is the right answer to your question. I'll do some research and get back to you if I got an decent answer. You should email the people at iPage as they probably could give you an answer..

Comment #1

Thanks, Mitch! That clears up a lot of confusion for me..

Right now, my header.php file shows only the logoff link, like this:.

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

Is there a way to add an 'else' statement to this so that if session isn't registered, it will show the login link instead?.

TIA,.

Terry..

Comment #2

I read your explanation about sprintf Mitch...now I understand more about how it works but I still don't sem to get one thing right. I want to add the customers lastname to his firstname when he logs in so that both names are displayed. So first I tried to display only the lastname to see if I can get that right.....what I did was change the words first into last in general.php around lines 944-950 (in total 3 times), but when I reload my page it displays 'welcome GUEST...' and not the customers last name. Can you tell me what I am doing wrong?.

TIA..

Comment #3

TerryK.

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

&nbsp;|&nbsp; <?php.

} ?>.

<a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo 'Login'; ?></a> </td>.

This post has been edited by.

Yesudo.com.

: 31 March 2004, 22:23..

Comment #4

Ignore me - just noticed the date on your post Terry...

Comment #5

Never mind I've found the answer finally this is what you need to do in general.php:.

// Return a customer greeting.

Function tep_customer_greeting() {.

Global $customer_id, $customer_first_name;.

//add customer details - osc@brightstorm.co.uk.

If (tep_session_is_registered('customer_id')) {.

$account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from "TABLE_CUSTOMERS" where customers_id = '"(int)$customer_id"'");.

$account = tep_db_fetch_array($account_query);.

$name = $account['customers_firstname']' '$account['customers_lastname'];.

$email = $account['customers_email_address'];.

// end add customer details.

$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($name), tep_href_link(FILENAME_PRODUCTS_NEW));.

} else {.

$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));.

}.

Return $greeting_string;.

}..

Comment #6

In /catalog/includes/languages/english.php, I see many instances where a variable is called using "%s" one of them being for the login link on index.php..

It appears to echo the relevant variable somehow, but how does it know what to put where? Where is that defined?.

The reason I ask is because I wanted to add a login link to my header.php file, and thought I could pull the code from the index page, but I don't know if that would work in the header as well..

TIA for any help / explanations..

Terry..

Comment #7

The %s, %d, etc are used by printf style output functions. You can read up on it in the.

PHP manual.

See the.

Sprintf function.

Specifically..

Basically, using your example of the defines in english.php, the line:.

Define('TEXT_GREETING_PERSONAL', 'Welcome back <span class="greetUser">%s!</span> Would you like to see which <a href="%s"><u>new products</u></a> are available to purchase?');.

Is called like this, from tep_customer_greeting() in includes/functions/general.php:.

$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($osC_Customer->first_name), tep_href_link(FILENAME_PRODUCTS_NEW));.

In this,.

Sprintf.

Interprets the string constant TEXT_GREETING_PERSONAL and substitutes each %s for string values it is passed, in order..

So, the first %s, between the <span>s, gets the first extra arg passed to sprintf, which is the output of $osC_Customer->first_name, and the second %s gets the other arg passed to sprintf, the output of the call to tep_href_link..

Then, in index.php, the result of the sprintf call, which is the TEXT_GREETING_PERSONAL with proper substitutions made by sprintf gets echoed out to the browser..

For your login, all you need to do is this:.

<a href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>">Secure Login</a>.

If you look at the TEXT_GREETING_GUEST define in english.php and it's sprintf call in tep_customer_greeting() in includes/functions/general.php you can see how it all works to get the Secure Login link above by substituting the extra args sent to sprintf for the %s's in the constant..

I think that's what you were asking for...hope it helps..

Mitch..

Comment #8


This question was taken from a support group/message board and re-posted here so others can learn from it.