Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 728 Views
  • philwhite
    Avatar
    Community Member
    24 Posts

    Event Calendar Link to this post

    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

  • philwhite
    Avatar
    Community Member
    24 Posts

    Re: Event Calendar Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Link to this post

    <% if UpcomingEvents %> oughta do it, no?

  • philwhite
    Avatar
    Community Member
    24 Posts

    Re: Event Calendar Link to this post

    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 if all the calendars are a 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 "{").

  • philwhite
    Avatar
    Community Member
    24 Posts

    Re: Event Calendar Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Link to this post

    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.

  • philwhite
    Avatar
    Community Member
    24 Posts

    Re: Event Calendar Link to this post

    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.

    728 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.