Hello, I have a site in 2.4.10 and I have numerous Calendars through out the site, which are all good.
However I have one quirky problem that I just can't figure out.
I have extended the Calendar with the following code:
class SocialEventHolder extends Calendar {
static $has_one = array (
'CalendarPDF' => 'File'
);
static $has_many = array (
'SocialEvents' => 'SocialEvent'
);
static $allowed_children = array('SocialEvent');
//static $hide_ancestor = 'Calendar';
public function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Files", new FileIFrameField('CalendarPDF',_t('SocialEventHolder.CALENDARPDF','PDF')));
return $f;
}
}
class SocialEventHolder_Controller extends Calendar_Controller {
public function AllSocialEvents() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$events = DataObject::get("CalendarDateTime","StartDate > NOW() AND CalendarDateTime.ClassName = 'SocialEventDateTime'","StartDate, StartTime", "LEFT JOIN SiteTree ON CalendarDateTime.EventID=SiteTree.ID LEFT JOIN SocialEvent ON CalendarDateTime.ID=SocialEvent.ID");
$doSet = new DataObjectSet();
foreach ($events as $event) {
if ($event->canView()) {
$doSet->push($event);
}
}
$doSet->setPageLimits($SQL_start, 3, $doSet->Count());
return $doSet;
}
....
And in my template I have this:
<% if AllSocialEvents %>
<% control AllSocialEvents.Pagination %>
<div class="news_box">
<div class="info<% control Event %><% if EventImage %> withimage<% end_if %><% end_control %>">
<h2><a href="$Link">$EventTitle</a></h2>
<p class="dates">DATE: $StartDate.format(l jS F Y)</p>
<% control Event %>
$Summary
<% if EventFlyer %>
<p><a href="$EventFlyer.Link" class="more" target="_blank">View the Flyer ></a></p>
<% end_if %>
<% end_control %>
</div>
<% control Event %>
<% if EventImage %>
<div class="news_thumbnail">
$EventImage.SetWidth(220)
</div>
<% end_if %>
<% end_control %>
<div class="clear"></div>
</div>
<% end_control %>
<% if AllSocialEvents.MoreThanOnePage %>
<div class="pagination">
<% if AllSocialEvents.PrevLink %><a href="$AllSocialEvents.PrevLink">< Prev</a><% end_if %>
<% control AllSocialEvents.Pages %>
<% if CurrentBool %><strong>$PageNum</strong><% else %><a href="$Link" title="Go to page $PageNum">$PageNum</a><% end_if %>
<% end_control %>
<% if AllSocialEvents.NextLink %><a href="$AllSocialEvents.NextLink">Next ></a><% end_if %>
</div>
<% end_if %>
<% end_if %>
This all works great... IF I am logged into the CMS. If not, it just displays a blank area where the social events belong. Is there something I need to set in order for this to be viewable by anyone? There is nothing about this page that should restrict viewing it to anyone. I have not set any restrictions for this page anywhere.
The function itself still runs (I echoed an alert with the ID of each record and they all popped up), and I have tried changing the function to only have
$events = DataObject::get("CalendarDateTime","StartDate > NOW() AND CalendarDateTime.ClassName = 'SocialEventDateTime'","StartDate, StartTime", "LEFT JOIN SiteTree ON CalendarDateTime.EventID=SiteTree.ID LEFT JOIN SocialEvent ON CalendarDateTime.ID=SocialEvent.ID");
return $events;
And this still does not display if not logged in.
If anyone can point me in the right direction that would be much appreciated.
Thanks