10375 Posts in 2190 Topics by 1707 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 585 Views |
-
Event Calendar

26 July 2010 at 11:10am
Very impressed with the vast majority of SilverStripe. Thanks everyone for all their work!
I have a demo site up and it's going down well, but I would like to design the home page to include a couple of teasers and perhaps any newsflashes. To do this, I'd like to lift the next forthcoming event from two different calendars (makes sense, regional and national) and (mis)use a third calendar not visible elsewhere on the site to store newsflashes with expiry dates.
Has anyone done anything similar or can anyone give me a pointer to the code I need to be looking at before I start rummaging around on my own?
TIA
-
Re: Event Calendar

29 July 2010 at 10:54am
You must be sick of answering that question. Sorry.
I have three teasers to three calendars working fine. Just one question, though.
How can I query if UpcomingEvents returns empty, so that I can suppress the entire teaser?
Sorry, PHP novice.
-
Re: Event Calendar

29 July 2010 at 7:51pm Last edited: 30 July 2010 11:18am
That's what I assumed, and it works if all the calendars are empty, but I have 3. As I say, I am a PHP novice (the last time I programmed, it was about 20 years ago in C, and before that in COBOL and FORTRAN; OOPLs are pretty foreign to me), and I simply can't see how to scope UpcomingEvents to the regional-events calendar only in the "if" statement.
<div id="Teaserbar" class="typography">
<div class="TeaserbarBox">
<h3>
Regional Events
</h3>
<% control UpcomingEvents(3,regional-events) %>
<ul id="Teaser2">
<b>$EventTitle</b>
<li><% control Event %>$Content.LimitWordCount(60)<% end_control %><br><a href="$Link"><% _t('MORE','more...') %></a></li>
</ul>
<% end_control %>
<div class="clear"></div>
</div>
<div class="sidebarBottom"></div>
<br>
...
</div>
works fine, but of course returns the header and an empty teaser box.<div id="Teaserbar" class="typography">
<% if UpcomingEvents %>
<div class="TeaserbarBox">
<h3>
Regional Events
</h3>
<% control UpcomingEvents(3,regional-events) %>
<ul id="Teaser2">
<b>$EventTitle</b>
<li><% control Event %>$Content.LimitWordCount(60)<% end_control %><br><a href="$Link"><% _t('MORE','more...') %></a></li>
</ul>
<% end_control %>
<div class="clear"></div>
</div>
<div class="sidebarBottom"></div>
<br>
<% end_if %>
...
</div>
works but only clears the box ifall the calendars area random calendar is empty.<div id="Teaserbar" class="typography">
<% if UpcomingEvents(3,regional-events) %>
<div class="TeaserbarBox">
<h3>
Regional Events
</h3>
<% control UpcomingEvents(3,regional-events) %>
<ul id="Teaser2">
<b>$EventTitle</b>
<li><% control Event %>$Content.LimitWordCount(60)<% end_control %><br><a href="$Link"><% _t('MORE','more...') %></a></li>
</ul>
<% end_control %>
<div class="clear"></div>
</div>
<div class="sidebarBottom"></div>
<br>
<% end_if %>
...
</div>Returns a parse error on the last line of HomePage.ss (unexpected "{").
-
Re: Event Calendar

30 July 2010 at 11:24am
Been struggling with this all day now. I really can't see why the arguments for the UpcomingEvents function work fine in the control statement, but deliver an error in the if statement. Just makes no sense to me. I suppose I could define three functions in HomePage.php, each of which explicitly checks one calendar that I need, but that seems awfully tiresome.
-
Re: Event Calendar

30 July 2010 at 12:24pm
Yeah, your <% if %> block is a bit too complex. SSViewer has some limitations.
You should probably just write a custom function..
public function UpcomingRegionalEvents() {
return $this->UpcomingEvents(3, "regional-events");
}That way you just need <% if UpcomingRegionalEvents %> and don't need multiple arguments.
-
Re: Event Calendar

30 July 2010 at 9:23pm
That, of course, works like a dream. I thought I was being even more stupid than usual.
Thank you so much.Now I'm on terra firma and only have the rest of the styling left to do.
| 585 Views | ||
|
Page:
1
|
Go to Top |

