Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2008
    Location
    Brampton, Cumbria, United Kingdom, United Kingdom
    Posts
    816
    Plugin Contributions
    2

    Default changing the greeting

    I am wanting to change to greeting on the home page to include the part of the day the customer is in for example if it is 2pm the greeting is Good afternoon and then either guest or their first name.

    I have been looking for php annotations. Can someone suggest a good place to look?

    Thanks
    Learning Fast.
    Eden Craft Supplies

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: php annotations

    Not familiar with the term php annotations. What is it that it is to imply?

    Also, on what are you basing the time of day? Is it server time? Doing a locality check based on ip address or something? Allowing the logged in customers to choose their time zone?

    Almost don't want to ask, but from an operatons perspective what financial benefit is this feature?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Mar 2008
    Location
    Brampton, Cumbria, United Kingdom, United Kingdom
    Posts
    816
    Plugin Contributions
    2

    Default Re: php annotations

    I have got the first bit sorted.
    HTML Code:
        <html>
        <body>
    
        <script type="text/javascript">
        var d = new Date();
        var time = d.getHours();
    
        if (time < 12) 
          {
          document.write("<b>Good morning!</b>");
          }
        if (time > 12 & time <18) 
          {
          document.write("<b>Good afternoon!</b>");
          }
        if (time > 12) 
          {
          document.write("<b>Good Evening</b>");
          }
        </script>
    
        </body>
    
        </html>
    I think the coding is correct. Just need to work out how and were to put it. Just now need to workout how to put 'welcome back Bill' or similar. I have found out that naming the person is already part of index.php
    Last edited by adb34; 11 Sep 2015 at 04:03 PM.
    Learning Fast.
    Eden Craft Supplies

  4. #4
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: php annotations

    Couple of things, this is all javascript and therefore don't see the tie yet to php annotations, but that said you'll be wanting to interact with other classes/ids already on the page. If they are not there yet, then will need to add them to the applicable code.

    The other thing is that the construct provided if not mistaken is still server locale date/time specific not local to the customer accessing the site. This is fine if only customers that are in your local timezone are the ones accessing (allowed to access) your site, otherwise someone in a different timezone will see the wrong representaton. Also, t appears that from 1200 to 1259 there is no representation. Suggest making the second if >= 12 & < 18
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Mar 2008
    Location
    Brampton, Cumbria, United Kingdom, United Kingdom
    Posts
    816
    Plugin Contributions
    2

    Default Re: php annotations

    Quote Originally Posted by mc12345678 View Post
    Couple of things, this is all javascript and therefore don't see the tie yet to php annotations, but that said you'll be wanting to interact with other classes/ids already on the page. If they are not there yet, then will need to add them to the applicable code.
    Sorry, I forgot to put 'I have found a JavaScript that can do what I am asking'.

    Quote Originally Posted by mc12345678 View Post
    The other thing is that the construct provided if not mistaken is still server locale date/time specific not local to the customer accessing the site. This is fine if only customers that are in your local timezone are the ones accessing (allowed to access) your site, otherwise someone in a different timezone will see the wrong representaton. Also, t appears that from 1200 to 1259 there is no representation. Suggest making the second if >= 12 & < 18
    I found the code on the W3 Schools website. The thing with your statement 12:01 is greater than 12:00
    Learning Fast.
    Eden Craft Supplies

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: php annotations

    Quote Originally Posted by adb34 View Post
    I found the code on the W3 Schools website. The thing with your statement 12:01 is greater than 12:00
    So where time = d.getHours(); if it is 12:01 then time will be 12:01 and not just 12?

    I'm sorry that I don't have the solution specifically, but am trying to understand and to close what looks like the issues. In looking for a way to present the time to a customer I was surprised to find code on stackexchange indicating that it was necessary to convert the returned date() value to the time local to the user as java/javascript is supposed to be all about the user's side. But not infallible resources. No conversion appears to be necessary for the date/time, but d.getHours() will return a whole number and therefore between 12:00 and 12:59 the. Variable time will equal 12 which is not specifically captured in the above code.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Mar 2008
    Location
    Brampton, Cumbria, United Kingdom, United Kingdom
    Posts
    816
    Plugin Contributions
    2

    Default Re: php annotations

    Quote Originally Posted by mc12345678 View Post
    So where time = d.getHours(); if it is 12:01 then time will be 12:01 and not just 12?

    I'm sorry that I don't have the solution specifically, but am trying to understand and to close what looks like the issues. In looking for a way to present the time to a customer I was surprised to find code on stackexchange indicating that it was necessary to convert the returned date() value to the time local to the user as java/javascript is supposed to be all about the user's side. But not infallible resources. No conversion appears to be necessary for the date/time, but d.getHours() will return a whole number and therefore between 12:00 and 12:59 the. Variable time will equal 12 which is not specifically captured in the above code.
    All true and I do appreciate all your help on all topics. I think I will put this on hold until I have sorted out the other stuff that is needed E.G. cookie control Etc.
    Learning Fast.
    Eden Craft Supplies

 

 

Similar Threads

  1. Welcome Greeting - Choosing the salutation for the first or last name
    By Peace Freak in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 13 May 2013, 10:04 AM
  2. v150 changing the position of greeting text
    By zzahid in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 23 Mar 2012, 01:24 AM
  3. changing user greeting
    By Mrchristoh in forum General Questions
    Replies: 3
    Last Post: 23 Jun 2009, 11:07 PM
  4. Replies: 2
    Last Post: 12 Sep 2007, 05:34 AM
  5. Changing the link of the Greeting message
    By KaeFeE in forum General Questions
    Replies: 4
    Last Post: 6 Feb 2007, 10:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg