Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding content to each page

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

Page: 1
Go to End
Author Topic: 723 Views
  • barryvanveen
    Avatar
    Community Member
    11 Posts

    Adding content to each page Link to this post

    Hi all,

    I've only started developing with Silverstripe a short while ago and got some questions. I want to include a list of upcoming events from a Google Calendar. I started by making a widget because I found the "how to make your own widget" tutorial. Now that I'm done, and the widget is working, I think it is not exactly what I need

    The list of events should be on every page, or at least at almost every page. Using a widget doesn't seem natural because one has to use the widget-tab to add it to each page.

    Then I thought I could just add a method to the Page class using this piece of code:

    class Page_Controller extends ContentController {
    ...
    function Events() {
    $oGCalendarWidget = new GCalendarWidget();
    return $oGCalendarWidget->Events();
    }
    ...
    }

    From what I understood this would make it accessible in the templates using <% control Events %>, but I don't get any results. Is this the correct way to do this kind of stuff?

    Cheers,

    Barry

  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: Adding content to each page Link to this post

    The <% control Events %> calls the function but you still need to display the results on the template.

    Are you doing that? it should be something like

    <% control Events %>
    <div class="EventName">$EventName</div>
    <div class="EventDate">$EventDate</div>
    <% end_control %>

    and so on.

  • barryvanveen
    Avatar
    Community Member
    11 Posts

    Re: Adding content to each page Link to this post

    Sorry for the late response. My problem has been (partially) solved. I was expecting it all to work because the widget worked, but I didnt't realise that this function would not use the widget-template. So now everythings works perfectly but is still don't know if this is "the right way" to solve it.

    I've got this library (Zend_Gdata) which is the google api I use, and I've got a class that has all the needed functionality. Where should you normally put those files in your sites hierarchy? Should I put the Calendar-class in mysite/code (seems the natural place) and where should i keep the library?

    Cheers

    Barry

    723 Views
Page: 1
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.