ワードプレスでジムのウェブサイトを作っているのですが、彼らはレッスンと時間を追加できるタイムテーブル プラグインを求めていました。
タイムテーブルが機能し、適切な日時に適切なレッスンが表示されますが、別の要件もありました。その時間のレッスンがない場合、その時間のテーブル行を表示したくないということです。例を次に示します。
Monday | Tuesday | etc
9.00
9.15 Fitness
9.30
9.45
10.00
10.15
10.45
11.00
11.15 Another lesson
この例では、 10.00 と 11.00 の間にレッスンはありません。だから私は 9.00 から 9.45 だけを表示し、時間 10 ですべての行を非表示にし、11.00 で再び開始するので、次のようになります。
Monday | Tuesday | etc
9.00
9.15 Fitness
9.30
9.45
11.00
11.15 Another lesson
ただし、これを行う方法がわかりません。タイムテーブルのデータを収集するコードと、テーブルを生成するコードを作成しました。テーブルを生成するコードは次のとおりです。
$table = '<table>';
$table .= '<thead>';
$table .= '<tr>';
$table .= '<th></th>';
foreach($this->arDays as $day => $id){
$table .= '<th>'.$day.'</th>';
// Display the days on top of the table.
}
$table .= '</tr>';
$table .= '</thead>';
$table .= '<tbody>';
foreach($arData['times'] as $time){
// I think here should be a check if we have to display the table rows,
// how ??
// Make a column with all the times
$table .= '<tr>';
$table .= '<td>'.date('H:i',$time).'</td>';
foreach($this->arDays as $day => $id){
// Then foreach time, foreach day check if there are lessons
$table .= '<td>';
// There is a lesson, display it in the timetable
if(!empty($arData[$day][$time])){
$arTimetable = $arData[$day][$time];
foreach($arTimetable as $oTimetable){
$table .= $oTimetable->oLesson->name;
}
}
$table .= '</td>';
}
$table .= '</tr>';
}
$table .= '</tbody>';
$table .= '</table>';
echo $table;
テーブル行を表示する必要があるかどうかをチェックするチェックを追加する必要があると思われる場所にコメントを追加しました。
誰かが私を助けてくれることを願っています!
ありがとう!!
編集:
これは、私のデータ配列が毎日どのように見えるかです:
Array
(
[monday] => Array
(
[1382086800] => Array
(
)
[1382087700] => Array
(
)
[1382088600] => Array
(
Lesson Object
)
配列内の毎日には、その日のすべての時間が含まれます (12 時間 / 15 分)