Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Adding an Image to the Event Calendar

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 3812 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    Well that's not the point. I'm just saying it's not just the values that are missing from your template. It's not even rendering the structure that you say you're using. If you view the source of your page, there is no <dl> tag that is supposed to be containing those values, so you might want to double check your template. Something isn't in the right place.

  • OutrunTheWolf
    Avatar
    Community Member
    34 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    I'm sorry UncleCheese, This is all my fault, I gave you the wrong URL. pls forgive me, here we go:

    http://www.srmpromotions.com/dj-factory/2009-08-08

    So back to my previous question:

    http://www.silverstripe.org/all-other-modules/show/263522?start=8#post263758

  • Hankins
    Avatar
    Community Member
    11 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    Hello OutrunTheWolf,

    I had a similar problem and fixed it using the following:

    Updated Solution:

    In your Template "CustomEventCalendar_Holder.ss" Use this convention: $Event.ItemName
    In your Template "CustomEvent_Entry.ss" Use this convention: $ItemName

    @UncleCheese, Is there a particular reason I am having to use these two different methods to display the variables in each template? There does not appear to be any difference between my two templates and I give control to Event before referencing any of the Custom Data.

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    sorry for warming up this years old threat but...

    ... I also had the wish to include a "teaser" pic to my events. I´ve read the Workshop tutorial but couldn´t get it to work (probably because I suck at .php). So I tried to modify the CalendarEvent.php (even though it´s recommended not to, but I have loads of events and all of them should get a pic ... I don´t wanna re-do all events in a workshop calendar again) and got it running so far... meaning it let´s me upload images but I don´t get them to show on my event pages
    I´ve already tried to insert images via CMS content field but this is horrible. No matter how I align the images they always stick to the left and act as block elements dividing my text!!! I would choose that over the event.image method but somehow it doesn´t seem to work (or is it just me?)
    any help would be much appreciated!!!

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    btw I just found this .vevent #eventImage img { float:right; } in the calendar.css ... so does this mean it´s supposed to contain images?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    You can decorate on to the event class to add an image field.

    CalendarEventDecorator.php

    CalendarEventDecorator extends DataObjectDecorator {

    public function extraStatics() {
    return array (
    'has_one' => array ('Image' => 'Image')
    );

    }

    public function updateCMSFields(&$fields) {
    $fields->addFieldToTab("Root.Content.Image", new ImageField('Image'));
    }
    }

    Apply the decorator in your _config:

    Object::add_extension("CalendarEvent","CalendarEventDecorator");

    Do a /dev/build

    Then on your template:

    $Event.Image

    or..

    <% control Event %>$Image.SetWidth(200)<% end_control %>

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Adding an Image to the Event Calendar Link to this post

    Thanks Uncle Cheese!

    Did exactly what you said...only that $Event.Image didn´t work for me. I changed that to $Image and there was my image

    thanks again for the code!!
    kind regards
    tchintchie

    3812 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.