For Visual PHP™
V předchozím článku jsme si ukázali, jak zobrazit data ve formě kalendáře pomocí komponenty
Table Calendar. Nyní si ukážeme, jak vytvořit kalendář, ve kterém půjde listovat i jednotlivými měsíci. Bude zde použita technologie AJAX (Asynchronous JavaScript and XML, která umožňuje načíst část stránky bez toho, aby bylo nutné celou stránku znovu celou generovat.
if ($month == "")
$month = (int)date("m", time());
if ($year == "")
$year = (int)date("Y", time());
$prevMonth = ($month-1 < 1 ? 12 : $month-1);
$prevYear = ($month-1 < 1 ? $year-1 : $year);
$nextMonth = ($month+1 > 12 ? 1 : $month+1);
$nextYear = ($month+1 > 12 ? $year+1 : $year);
$months = array("leden", "únor", "březen", "duben", "květen", "červen", "červenec", "srpen", "září", "říjen", "listopad", "prosinec");
$bom = TDateTime::BOM(mktime(0, 0, 0, $month, 1, $year))->asString();
$eom = TDateTime::EOM(mktime(0, 0, 0, $month, 1, $year))->asString();Pomocí AJAX totiž budeme předávat parametry $month a $year, které budou určovat, který měsíc a rok se má zobrazit. Proměnné $bom a $eom určují datum prvního a posledního dne v daném měsíci v SQL formátu a využijeme je v samotné komponentě Table Calendar. Proměnné $prevMonth, $prevYear, $nextMonth a $nextYear pak využijeme u tlačítek pro posun mezi měsíci.Datum od: {php: $bom}
Datum do: {php: $eom}
Teď už zbývá pouze do tohoto layoutu doplnit zobrazení měsíce a roku a tlačítek pro posun mezi měsíci. Pro zobrazení aktuálního měsíce a roku vložte tento PHP skript:echo $months[$month-1]."/".$year;A pak už jenom stačí vytvořit 2 odkazy pro posun mezi měsíci:
<a onclick="loadCalendar({php:$prevMonth},{php:$prevYear});return false;">Předchozí měsíc</a>
<a onclick="loadCalendar({php:$nextMonth},{php:$nextYear});return false;">Další měsíc</a>
Jak je vidět, není to klasický odkaz, ale po kliknutí se volá JavaScript, na který se teď podíváme.function loadCalendar(month, year)
{
// najdeme div, který obsahuje původní kalendář a jehož obsah chceme nahradit
var container = document.getElementById("calendarDiv");
// načteme pomocí AJAX layout s názvem calendar, předáváme parametry month a year
var content = AJAX.getLayout("calendar", {'month':month,'year':year});
// nahradíme obsah divu načteným novým kalendářem
container.innerHTML = content;
}... kalendář, kterým lze procházet je hotový
Some properties published in this article can only be functional with the latest core version. If you have any older core version, we recommend you to update to the latest version.
| Fotogalerie | 5/10/2012 |
| Section: Tvorba prezentací | |
| Chyba v hromadné korespondenci, nelze odeslat příloha (nová verze | 4/6/2012 |
| Section: Bug reporty | |
| AntiSpam obrázek | 4/6/2012 |
| Section: Programování | |
| Chyba při opravách textů | 4/4/2012 |
| Section: Bug reporty | |
| Admin může smazat Developera, je to ok? | 3/27/2012 |
| Section: Bug reporty | |
| Mapa webu | 3/19/2012 |
| Section: Tvorba prezentací | |
| Weather Component Update
november 18, 2011 |
|
Server weather.com decided to stop providing weather information for free and passed to the paid version (about $ 60 per month). For this reason, we were forced to modify the Weather component to pulling weather information from another data source, namely from the server www.worldweatheronline.com . This site also provides information about weather all around the world, but the amount of information is smaller than the original source. For proper functionality of the Weather component please update core to version 1.7.9.638. |
| Added new tutorials
october 4, 2011 |
|
He added new instructions Using another HTML editor |
English

