10448 Posts in 2223 Topics by 1719 members
| Go to End | Next > | |
| Author | Topic: | 3276 Views |
-
Adding an Image to the Event Calendar

29 June 2009 at 3:49am
Hello all,
I'm trying to add an Image field to the Event Calendar. I followed Tutorial 2, and ended up with this in:
CalendarEvent.php
class CalendarEvent extends Page
{static $has_one = array (
'EventPhoto' => 'Image');
}public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Images", new ImageField('EventPhoto'));return $f;
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:
<div id="Photo">
$EventPhoto
</div>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?
-
Re: Adding an Image to the Event Calendar

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.
-
Re: Adding an Image to the Event Calendar

29 June 2009 at 5:03am Last edited: 29 June 2009 5:40am
Thanks again Cheese.
EDIT
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?
-
Re: Adding an Image to the Event Calendar

29 June 2009 at 8:40am
In your mysite or theme directory. /templates/Layout/MyCalendarClass.ss -- just like the module has it set up.
-
Re: Adding an Image to the Event Calendar

29 June 2009 at 9:37am Last edited: 29 June 2009 9:38am
Well,
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:
mysite/code/
Workshop.php
WorkshopHolder.phpmysite/templates/Layout/
Workshop.ss
WorkshopHolder.ssIf you get a chnace to take a look at my files pls do, it might reveal where i'm going wrong.
Thanks
-
Re: Adding an Image to the Event Calendar

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.
| 3276 Views | ||
| Go to Top | Next > |

