Skip to content

Commit fa30855

Browse files
committed
Display conference dates prominently on conferences page and homepage (#1606)
Show finalTeaserDate under each conference title on the conferences page and in the homepage sidebar. Replace the outdated $CONF_TEASER array with NewsHandler::getConferences() to access date information.
1 parent 80d3119 commit fa30855

2 files changed

Lines changed: 48 additions & 14 deletions

File tree

conferences/index.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
$date = date_format(date_create($entry["updated"] ?? $entry["published"]), 'Y-m-d');
2222
$content .= '<div class="newsentry">';
2323
$content .= '<h3 class="newstitle title"><a href="' . $MYSITE . $link . '" id="' . $id . '">' . $entry["title"] . '</a></h3>';
24+
25+
if (!empty($entry["finalTeaserDate"])) {
26+
$confDate = date_create($entry["finalTeaserDate"]);
27+
if ($confDate) {
28+
$content .= '<p class="conference-date"><strong>' . date_format($confDate, 'F j, Y') . '</strong></p>';
29+
}
30+
}
31+
2432
$content .= '<div class="newsimage">';
2533

2634
if (isset($entry["newsImage"])) {
@@ -33,7 +41,14 @@
3341
$content .= '</div>';
3442
$content .= '</div>';
3543

36-
$panels .= sprintf('<p class="panel"><a href="%s">%s</a></p>', $entry["newsImage"]["link"] ?? $link, $entry["title"]);
44+
$panelExtra = '';
45+
if (!empty($entry["finalTeaserDate"])) {
46+
$confDate = date_create($entry["finalTeaserDate"]);
47+
if ($confDate) {
48+
$panelExtra = ' <small>' . date_format($confDate, 'M j, Y') . '</small>';
49+
}
50+
}
51+
$panels .= sprintf('<p class="panel"><a href="%s">%s</a>%s</p>', $entry["newsImage"]["link"] ?? $link, $entry["title"], $panelExtra);
3752
}
3853
$content .= "</div>";
3954

index.php

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,44 @@
141141
// Print body of home page.
142142
echo $content;
143143

144-
// Prepare announcements.
145-
if (is_array($CONF_TEASER)) {
144+
// Prepare announcements from conferences.
145+
$conferences = (new NewsHandler())->getConferences();
146+
if ($conferences) {
147+
$confsByCategory = [];
148+
foreach ($conferences as $entry) {
149+
foreach ($entry['category'] as $cat) {
150+
if ($cat['term'] === 'conferences' || $cat['term'] === 'cfp') {
151+
$confsByCategory[$cat['term']][] = $entry;
152+
break;
153+
}
154+
}
155+
}
146156
$conftype = [
147-
'conference' => 'Upcoming conferences',
157+
'conferences' => 'Upcoming conferences',
148158
'cfp' => 'Conferences calling for papers',
149159
];
150160
$announcements = "";
151-
foreach ($CONF_TEASER as $category => $entries) {
152-
if ($entries) {
153-
$announcements .= '<div class="panel">';
154-
$announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] . '</a>';
155-
$announcements .= '<div class="body"><ul>';
156-
foreach (array_slice($entries, 0, 4) as $url => $title) {
157-
$title = preg_replace("'([A-Za-z0-9])([\s:\-,]*?)call for(.*?)$'i", "$1", $title);
158-
$announcements .= "<li><a href='$url' title='$title'>$title</a></li>";
161+
foreach ($confsByCategory as $category => $entries) {
162+
$announcements .= '<div class="panel">';
163+
$announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] . '</a>';
164+
$announcements .= '<div class="body"><ul>';
165+
foreach (array_slice($entries, 0, 4) as $entry) {
166+
$title = preg_replace("'([A-Za-z0-9])([\s:\-,]*?)call for(.*?)$'i", "$1", $entry['title']);
167+
$link = $entry['newsImage']['link'] ?? preg_replace('~^(http://php.net/|https://www.php.net/)~', '', $entry['id']);
168+
$dateInfo = '';
169+
if (!empty($entry['finalTeaserDate'])) {
170+
$confDate = date_create($entry['finalTeaserDate']);
171+
if ($confDate) {
172+
$dateInfo = ' <small>' . date_format($confDate, 'M j') . '</small>';
173+
}
159174
}
160-
$announcements .= '</ul></div>';
161-
$announcements .= '</div>';
175+
$announcements .= "<li><a href='" . htmlspecialchars($link) . "' title='" . htmlspecialchars($title) . "'>" . htmlspecialchars($title) . "</a>$dateInfo</li>";
176+
}
177+
$announcements .= '</ul></div>';
178+
if (count($entries) > 4) {
179+
$announcements .= '<div class="body"><a href="/conferences">View all &raquo;</a></div>';
162180
}
181+
$announcements .= '</div>';
163182
}
164183
} else {
165184
$announcements = '';

0 commit comments

Comments
 (0)