Calendar logic - if today add button to tomorrow

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Calendar logic - if today add button to tomorrow

Beitragvon Michael_S » Mi 14. Dez 2011, 17:55

Hi,

I would like to use a if statement to add a radio button to calendar days but I'm having problems with the logic. The logic in plain English would be:

IF TODAY ADD BUTTON TO TOMORROW

I can add radio buttons to all future Tuesdays but can't workout how to add the radio button to Tuesday in the same week if the day is Monday and the hour pre-noon (<12). I guess I would need a nested if statement for this but can't work out the logic.

Any help or pointers would be appreciated.

Code: Alles auswählen

<?php

// IF MONDAY & PRE-NOON (<12)
if ((date("Y-m-d",$GLOBALS["lv"]->calendar_struct["date"]) == $today) && 
(date("l",$GLOBALS["lv"]->calendar_struct["date"]) == 'Monday') && 
($hour < '12')) { 

// --- ADD RADIO BUTTON FOR NEXT DAY (TUESDAY)

// if statement
echo '[radio button]';
// end if statement

} elseif (
// ADD RADIO BUTTON FOR FUTURE TUESDAYS
(date("Y-m-d",$GLOBALS["lv"]->calendar_struct["date"]) > $today) && 
(date("l",$GLOBALS["lv"]->calendar_struct["date"]) == 'Tuesday')
) {
echo '[radio button]';
};

?>
This is a PHP question but would be useful for anyone using the calendar function.
Production Area
London, UK
http://productionarea.com

mokraemer
Senior Member
Beiträge: 3619
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Calendar logic - if today add button to tomorrow

Beitragvon mokraemer » Mi 14. Dez 2011, 22:32

For your simple question the code looks ways to complicated, so I'm not sure if I understood what you wanted.
If you just want to add a button to the next day if the shown date is today, the logic is only

Code: Alles auswählen

<we:ifCurrentDate>
...
</we:ifCurrentDate>
Currently I don't understand why are you extracting the weekday.
webEdition-Kern-Entwickler

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Calendar logic - if today add button to tomorrow

Beitragvon Michael_S » Mi 14. Dez 2011, 23:16

Hi,

I wish it was as simple as just showing the current day :-(

The calendar is being used for fresh food products which can only be delivered on specific days of the week, the web user can also select a next day delivery if the order is placed before 12 midday. To make things more complicated the delivery days change depending on the product.

When I have worked out the logic or we tags I will present a radio button for the web user to select his/her preferred delivery day.
mokraemer hat geschrieben:For your simple question the code looks ways to complicated, so I'm not sure if I understood what you wanted.
If you just want to add a button to the next day if the shown date is today, the logic is only

Code: Alles auswählen

<we:ifCurrentDate>
...
</we:ifCurrentDate>
Currently I don't understand why are you extracting the weekday.
Production Area
London, UK
http://productionarea.com


Zurück zu „webEdition Basic Version“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 8 Gäste