10987 Posts in 2724 Topics by 1817 members
|Go to End||Next >|
29 June 2009 at 3:49am
I'm trying to add an Image field to the Event Calendar. I followed Tutorial 2, and ended up with this in:
class CalendarEvent extends Page
static $has_one = array (
'EventPhoto' => 'Image'
public function getCMSFields()
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Images", new ImageField('EventPhoto'));
That works fine as far as I can see. In the CMS, under Page Type Calendar Event there is an image tab, and it lets me upload the image.
Th problem comes with the site, when I try to get the image in the code:
I just end up with a "Website Error" Screen, when I acces the particular event.
Does anyone have any ideas on where i'm going wrong?
29 June 2009 at 4:42am
I recommend you read the tutorial on extending the EventCalendar in the SS Wiki. I go through several levels of customization in there, including adding an image. You should not be modifying the core event_calendar code because when updates come out you'll lose your changes. You need to extend the classes in your mysite folder to keep your changes isolated.
29 June 2009 at 5:03am Last edited: 29 June 2009 5:40am
Thanks again Cheese.
Ok Cheese, I ran through the extending the event calender tutorial, I understand what is happening. But when you reach the end:
Setting up the templates
The next thing we have to do is set up templates for both the WorkshopHolder and Workshop class that include our new fields.
Weâ€™ll start by copying the base calendar template from /event_calendar/templates/Layout/Calendar.ss
Now, somewhere below the content, we need to add some of the custom Workshop fields we created. Remember, the Events control returns CalendarDateTime objects, so we need to refer to the $Event accessor to get to those fields.
Weâ€™ll add the following below the $_Content line...........
So, I copy the content from the original calendar.ss and calenderholder.ss files, into Workshop.ss and WorkshopHolder.ss, added the additional code. But where do I save the Workshop.ss files?
29 June 2009 at 8:40am
In your mysite or theme directory. /templates/Layout/MyCalendarClass.ss -- just like the module has it set up.
29 June 2009 at 9:37am Last edited: 29 June 2009 9:38am
After a lot of work, I haven't managed to get any further. I can't seem to get image working for each individual event, it doesn't show up.
I have attached my ss file.
To make sure:
If you get a chnace to take a look at my files pls do, it might reveal where i'm going wrong.
30 June 2009 at 1:37am
Can you post your PHP file?
30 June 2009 at 2:27am
Yeah, here we go
30 June 2009 at 2:56am
And just to be sure, in the CMS the page type is WorkshopHolder and the event is created as a Workshop? What happens when you put some static text on that template? Does it render? Just want to make sure it's reading the right template.
|Go to Top||Next >|