5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 604 Views |
-
Adding content to each page

18 May 2010 at 8:45am
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
-
Re: Adding content to each page

18 May 2010 at 10:36am
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.
-
Re: Adding content to each page

23 May 2010 at 12:34pm
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
| 604 Views | ||
|
Page:
1
|
Go to Top |


