Guest Posted April 17, 2004 Share Posted April 17, 2004 I removed the question at the top of the Index asking whether you want to sign up or log in. Now I'd like to put it in the body of the text and am can't find the orignal code that was used. Being a newbie to PHP, I don't know the code. Can anyone give it to me? I'd like to put this in the body: You don't have to sign up for an account, but if you create a new account, you will be able to ... and have create a new account be a link. I don't want to put the URL but rather the appropriate PHP code. Thanks. B) Link to comment Share on other sites More sharing options...
zzfritz Posted April 18, 2004 Share Posted April 18, 2004 The lines you probably removed from index.php are <tr> <td class="main"><?php echo tep_customer_greeting(); ?></td> </tr> which is just above were TEXT_MAIN is emitted. The function tep_customer_greeting is found in includes/functions/general.php, where you can see it uses the variable TEXT_GREETING_PERSONAL as the template for registered customers and TEXT_GREETING_GUEST for others. Don't modify the function itself, but edit the define of TEXT_GREETING_GUEST in includes/languages/english.php. Be sure to leave the "%s" tokens, as the function replaces them with links to (in order) the login and create account pages. Just change the other text to suit yourself. Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2004 Share Posted April 18, 2004 Thanks for your reply. I'm confused. I put the code in like this. (I know how to change the text in english.php but am not sure how the code should look in the body of the index.php. This doesn't work: However, if you <?php echo tep_customer_greeting(); ?><a href="%s"><u>create an account</u></a>, your shopping experience at westportartist.com will be faster, easier and customized. Here is my lame draft so far: http://www.bluemoonproduction.net/catalog/index.php Link to comment Share on other sites More sharing options...
zzfritz Posted April 18, 2004 Share Posted April 18, 2004 Maybe I didn't make it clear enough. When you wrote you had "removed the question at the top of the Index", I understood that to mean you had edited out the row of index.php quoted in my reply. If you did, put it back. After the code of index.php is restored to its original form, restrict your edits to the language file. Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2004 Share Posted April 18, 2004 I put this back in: <td class="main"><?php echo tep_customer_greeting(); ?></td> But I'm not sure where to put the tokens. "%s" The link is currently not pointing to anything or working because the tokens aren't right, as witnessed here: http://www.bluemoonproduction.net/catalog/index.php Sorry for the confusion. :blink: Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2004 Share Posted April 18, 2004 In /includes/languages/english.php add: define('TEXT_GREETING_GUEST', 'Welcome <span class="greetUser">Guest!</span> Would you like to <a href="http://mail.surfcomputing.com/jump/%s"><u>log yourself in</u></a>? Or would you prefer to <a href="http://mail.surfcomputing.com/jump/%s"><u>create an account</u></a>?'); This is the original. In index.php starting around line 291 find: <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> Add this after: <tr> <td class="main"><?php echo tep_customer_greeting(); ?></td> </tr> Hope this helps. Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2004 Share Posted April 18, 2004 Thank you! This is very helpful. :) Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2004 Share Posted April 18, 2004 Just looked at earlier post: define('TEXT_GREETING_GUEST', 'Welcome <span class="greetUser">Guest!</span> Would you like to <a href="http://mail.surfcomputing.com/jump/%s"><u>log yourself in</u></a>? Or would you prefer to <a href="http://mail.surfcomputing.com/jump/%s"><u>create an account</u></a>?'); USE instead: define('TEXT_GREETING_GUEST', 'Welcome <span class="greetUser">Guest!</span> Would you like to <a href="%s"><u>log yourself in</u></a>? Or would you prefer to <a href="%s"><u>create an account</u></a>?'); Sorry about that! Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2004 Share Posted April 19, 2004 Okay, thanks! That looks more familiar. :) Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2004 Share Posted April 19, 2004 Any idea why the index.php script uses the following: tep_customer_greeting instead of: tep_TEXT_GREETING_GUEST I don't get how it references the former code when that doesn't seem to be defined anywhere. :unsure: Just wondered. ~ PHP Novice Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2004 Share Posted April 19, 2004 tep_customer_greeting I think is is used as a variable depending on being logged in or not as to what is returned. (Either Welcome Guest or Welcome back Bob or whatever) Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2004 Share Posted April 19, 2004 How come it doesn't work when I put the same tokens in the TEXT_MAIN definition of index.php? I'd rather have it embedded within the body of the index, rather than at the top. Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2004 Share Posted April 19, 2004 Any idea why the index.php script uses the following: tep_customer_greeting instead of: tep_TEXT_GREETING_GUEST I don't get how it references the former code when that doesn't seem to be defined anywhere. :unsure: Just wondered. ~ PHP Novice tep_customer_greeting is a call handled by /includes/functions/general.php by the following: //// // Return a customer greeting function tep_customer_greeting() { global $customer_id, $customer_first_name; if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) { $greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_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; } Link to comment Share on other sites More sharing options...
zzfritz Posted April 19, 2004 Share Posted April 19, 2004 No, there is nothing called tep_TEXT_GREETING_GUEST. Follow this step by step. The function tep_customer_greeting() is called from index.php, which echos the result; the function code is in includes/functions/general.php. tep_function_greeting (take a look at it) tests whether the customer is logged in, and returns alternative messages for customers or anonymous guests. The string it returns in either case is constructed with the assistance of a sprintf function (built in to php) whose first parameter is the key to constructing the string, TEXT_GREETING_PERSONAL or TEXT_GREETING_GUEST. These identifiers are mapped to language files based on what is the current language in the session, so you find their define statements in includes/languages/english.php (or german.php, ...). The other parameters of the sprintf function call are used in order, to replace a series of "%s" tokens in TEXT_GREETING_PERSONAL and TEXT_GREETING_GUEST. So, the sprintf function takes the string 'Welcome <span class="greetUser">Guest!</span> Would you like to <a href="%s"><u>log yourself in</u></a>? Or would you prefer to <a href="%s"><u>create an account</u></a>?' and puts a link to the logon page in place of the first %s, and puts a link to the create account page in place of the second %s. All you should do is edit the string to your liking, but keeping the first %s as the link to the logon page and the second %s as the link to the create account page. This may seem peculiar, but a consequence of modularity. Link to comment Share on other sites More sharing options...
Guest Posted April 23, 2004 Share Posted April 23, 2004 Thanks for the explanation. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.