Silverstripe Version: 4.1.2
Question:
This is sort of related to a previous query I had, although that one was resolved (thanks for those who helped).
Basically, I have a DataObject for events which can either be Interview
or General
, and I’m trying to display these on a page, using the below code snippets:
EventEntry.php
private static $db = [
"Title" => "Text",
"Type" => 'Enum(array("Interview","General"))',
"Location" => "Varchar(255)",
"Date" => DBDate::class,
"Time" => "Varchar(100)",
"Description" => "Text"
];
PageController.php
public function Events()
{
return MySite\CalendarEntry::get();
}
Page.ss
<div class="row my-3">
<div class="col-md-6">
<h2 class="text-center">Upcoming Interviews</h2>
<% if $Events.Filter('Type', 'Interview').Filter('Date:GreaterThanOrEqual', $Now.Format(Y-M-d)) %>
<% loop $Events.Filter('Type', 'Interview').Filter('Date:GreaterThanOrEqual', $Now.Format(Y-M-d)).Limit(4) %>
<% if $Odd %><div class="row py-3"><% end_if %>
<div class="col-md-6">
<% include CalendarEntry HideImage=true %>
</div>
<% if $Even || $FromEnd == 1 %></div><% end_if %>
<% end_loop %>
<% else %>
<p>We don't current have any interviews planned.</p>
<p>Watch this space, and follow us on social media for the latest updates.</p>
<% end_if %>
</div>
<div class="col-md-6">
<h2 class="text-center">Upcoming Events</h2>
<% if $Events.Filter('Type', 'General').Filter('Date:GreaterThanOrEqual', $Now.Format(Y-M-d)) %>
<% loop $Events.Filter('Type', 'General').Filter('Date:GreaterThanOrEqual', $Now.Format(Y-M-d)).Limit(4) %>
<% if $Odd %><div class="row py-3"><% end_if %>
<div class="col-md-6">
<% include CalendarEntry HideImage=true %>
</div>
<% if $Even || $FromEnd == 1 %></div><% end_if %>
<% end_loop %>
<% else %>
<p>We don't know of any events being planned at the moment.</p>
<p>Want a shout out for yours? Get in touch today.</p>
<% else_if %>
</div>
</div>
My expected result here would be false
on both if
s, so the “no interviews planned” and “no events planned” would be shown. However, what I actually get, is this:
No events, no error, no “no events planned” - just empty space.
When I do a query view using showinline=1
, I can only see 1 count query related to any of this, and that’s it.
I may be missing something completely obvious (likely), but I’m going around in circles here, so any help or pointers would be brilliant.
Thanks in advance