Event listing page

Permalink
Hi,
I have a HUGE problem that I'm struggling to solve. I need to create an event listing page. Events should be grouped by date and appear under each day chronologically by time. That sounds simple enough right? Well the problem is that I have a bunch of pages ("Shows") each with dates loaded against it using the Event Dates Attribute which installed as part of the Pro Events add-on. This allows me to display all the dates and times for that Show on the page as a table of "Show times".
What I need is another listing page which aggregates all these Show pages using their Event Dates attributes and then groups them by date and sorts by time. Something like this:
Saturday, 13 February
11am Oliver
3pm Phantom of the Opera
7pm Cats
Sunday, 14 February
11am Oliver
3pm Phantom of the Opera
7pm Jesus Christ Superstar
Monday, 15 February
8pm Fiddler on the Roof
and so on.
What I don't want to do is have to enter another set of Shows, dates and times to display on my listing page.
1. Is there anyway that Pro Events will help me do this?
2. Does anyone know if there is an add-on which will allow me to do this?
3. If there is currently no add-on, what would you suggest I do?
Thanks!
Choppie

Choppie
View Replies:
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Choppie,

You can try this:
<div class="event-list">
<?php
/*Get the Pages*/
// create a new PageList object
$list = new \Concrete\Core\Page\PageList();
// create the expiration date
// - the expiration date for events
// - expired events are not included in the list
// use strtotime() to convert a string into a Unix timestamp
// - -1 day would be the current time, minus 24 hours (an event will be listed for 24 hours after its list time)
// - "West Side Story - Tuesday February 16th, 2016 6:54am" will be listed until Wednesday February 17th, 2016 6:54am
// use date() to convert the Unix timestamp into a MySQL timestamp - 'Y-m-d H:i:s'
$expirationDate = date('Y-m-d H:i:s', strtotime('-1 day'));
// filter the page list results by the "event_date_time" Date/Time attribute handle
// - compare the event_date_time attribute of a page with the expirationDate
Choppie replied on at Permalink Reply
Choppie
MrKDilkington,

Thank you SO MUCH! I tried adding this to my page using a PHP block.

I do however get the following error:
"Call to a member function getController() on a non-object"

I've tried debugging by adding it piece-by-piece and the error seems to occur around this spot:
$expirationDate = date('Y-m-d H:i:s', strtotime('-1 day'));
$list->filterbyAttribute('event_date_time', $expirationDate, '>=');
$ak_date_time_attribute = 'ak_event_date_time';
$list->sortBy($ak_date_time_attribute, 'asc');
$pages = $list->getResults();


I think it may be the last function
getResults()
but not sure.

Did I add this to my page correctly ie using a PHP block? Or am I meant to add a Page List Block and then use the code you so kindly provided as a template? Apologies if I haven't done it correctly, as you can tell I'm still on a very steep learning curve.

Also, not sure if it makes a difference but one thing that I don't think I previously mentioned is that the "Show pages" are children of the listing page. So it makes it slightly easier to "find the pages" and then group by date and sort by time - I think.

There is also already another page list block on the page which shows the Shows - titles and images. Will this cause anything to conflict?

Thank you for all your help so far! I really appreciate it!

Cheers,
Choppie
Choppie replied on at Permalink Reply
Choppie
Hi,

Even when I add a Page List block and use the code as a template, I still get the same error. So must be something else going on.

Cheers,
Choppie
MrKDilkington replied on at Permalink Reply
MrKDilkington
@Choppie

"Thank you SO MUCH! I tried adding this to my page using a PHP block."

I am not sure if using a block to add PHP is a recommended approach. One make shift approach would be adding the code in a custom template for the Page List block. Which would effectively bypass the block and use it just as a way to place the code. Another approach would be embedding the code into page template files.

The example code I supplied requires customizing it to your requirements. The first thing that needs to be changed is the attribute handle. In the code I use "event_date_time", your attribute handle is likely to be different. You will need to go to the Attributes page and look for the attribute and the handle it uses.
Choppie replied on at Permalink Reply
Choppie
@MrKDilkington

Yes, duh! I should have gone through the code a bit more carefully. I understand it in theory (most of it) but not the syntax etc. I have updated the Event Dates attribute with it's proper handle 'event_multidate'. The good news is that my page no longer breaks. Bad news is that my block is blank and none of my "Show pages" display.

I've checked the dates stored against my pages and they are all current ie not older than 24 hours.

I then changed the >= to a <= for the $expirationDate:
$list = new \Concrete\Core\Page\PageList();
$expirationDate = date('Y-m-d H:i:s', strtotime('-1 day'));
$list->filterbyAttribute('event_multidate', $expirationDate, '<=');

which now pulls through the pages but they are all listed as THURSDAY, 1 JANUARY 12:00am.

I'm guessing it has to do with the display part of the code? Logic tells me that it's reading the attribute now and getting the list of pages, but not displaying the correct values? I'll keep trying and see what I can figure out.

Thanks for all your help once again!
Choppie
MrKDilkington replied on at Permalink Reply 1 Attachment
MrKDilkington
@Choppie

I am attaching a custom block you can try. It is the Page List block with added filtering for pages with a Date/Time attribute and an expiration. It comes with three custom templates for grouping by year/month/day, month/day, and day.

I have tested it and there should be no stand out issues, but I provide it as is without warranty.

This should work if your dates are default Date/Time attributes. They will not work if ProBlog uses a custom attribute. Do you know if the "event_multidate" is a custom attribute installed with ProBlog?
Choppie replied on at Permalink Reply 1 Attachment
Choppie
@MrKDilkington

Yeah, I think the attribute I've used ie Event Dates ('event_multidate') was installed along with the Pro Events add-on. I'm not sure how to check if it's a "normal" date/time type attribute. I've attached what I can see. There are also 3 folders under >packages>proevents>attributes one being multi_date so assume it's all custom.

I think it's maybe time for me to find a developer who can look at the stuff more closely? What do you recon? I'll give the code you've provided in the previous post a go and see what happens.

Cheers,
Choppie
MrKDilkington replied on at Permalink Reply
MrKDilkington
@Choppie

The code and block I provided won't work with the attribute you describe.

Have you tried displaying the attribute using the Page Attribute Display block? If so, what does it display?
AndyJ replied on at Permalink Reply
Hi Choppie,

apologies for butting in and please ignore as appropriate.

Do none of the pro event list block templates do anything close to what you are looking to do?

It's a while since I looked at this plugin but there are a lot of templates for the event list block, I'm pretty sure some of them must do something fairly similar to what you want to do.

On the backend these templates are stored in:

/packages/proevents/blocks/pro_event_list/templates

you could take a look (just look) at some of these to see how they are built.

If none of them are exactly right for your purposes you could copy the closest one as a new template and change that without hacking the original pro-events code.

Have you used the event list block and tried all of the various templates with the various different filters to see if any does what you want or close to what you want?
Choppie replied on at Permalink Reply
Choppie
Hi AndyJ,

Please don't apologies for "butting in". I appreciate any help I can get at this stage.

I've tried all the templates like you suggested.

I think the issue is that I'm probably not using this add-on correctly or as indended. It's quite weird as it has a function where you can load events which is separate from pages, but then at the same time it has the Event Dates attribute where you can add dates against a page itself. What I can't figure out is why would the attributes be there in the first place.

Also, the central function where I think you are meant to add events really doesn't have a very rich "content" area so I can't really add a poster, info, show times, etc and get it to display nicely. Which is why I opted to create individual show pages containing custom blocks and then add show dates and times against each page itself.

It would suck if one had to create individual show pages, create events using the central function and then link them up. Would seem like a lot of double handling.

Any way, I've raised a support ticket with the developer so will see if I get a response from this - fingers crossed. Otherwise I might have to hire a dev to help with this.

Thanks for the input any way!
Cheers,
Choppie
Choppie replied on at Permalink Reply
Choppie
Hi,

Okay something happened. On my "listing page" I set a "Calendar" attribute to true. This generated a list of events for me in the Pro Events "Events List". So I can see all my pages/shows listed there now.

I still can't get the to display on my page using the Event List block but I feel like I'm making progress.

Cheers,
Choppie
AndyJ replied on at Permalink Reply
Hi Choppie,
the way Pro Events works is:

when you enter an event via the dashboard you add a record or records to the various btProEvent database tables. The most important of these being the btProEventDates - this basically stores all of your event information at a line item level - and among other things it links each diescrete eventID to each event page ID.

When you create the event - as well as creating the entry(ies) in the table it also creates an event page which lives within the sitemap and has the various event information you entered stored as page attributes (I'm being general here).

So, you automatically have a relationship between the database tables and the pages and the Pro Events dashboard pages are really your source of truth.

If you ever want to delete an event you should delete it from the Pro events interface and the website page associated with the event will automatically be deleted as well.

So, the fields in the btProEventDates table like date, start time etc also equate to the various page attributes.

Therefore you have 2 ways of sorting and presenting the events - by page list / modified page list.

Or, by using the custom Pro Event List block - which like I said before has lots of different templates.

Much of what Pro Events does is in a large helper file called eventify - you'll see numerous calls to this in the various templates.

I would think you 'should' be able to get where you want by copying one of the existing templates and creating a new one as a basis for modifications.

If you get really stuck - are hitting a wall I can likely help out if you aren't getting any from anywhere else.
Choppie replied on at Permalink Reply
Choppie
Hi @AndyJ and @MrKDilkington,

I have no idea if what I did will break things but I ended up doing the following:
- changed all my show pages to use the Event page type
- stored my show/event dates against each page using the Event Dates attribute
- set the Calendar attribute against my "Now showing" page to true
- this generated a "Now showing" calendar and its events in my Event List (ProEvents) - I assume this would then feed into the applicable database tables?
- removed a bunch of code from view.php under \packages\proevents\blocks\content\templates\event_post; to stop the event info from automatically displaying on my event pages. I already have some custom blocks on this page for adding the show poster, description, show times, some share buttons, etc. This is much richer than what the automated content block from ProEvents allow me to do.
- added an Event List block on my "Now showing" page, applied a custom template and styled it.
All looks to work okay for now - here's to hoping it stays the same.

The only thing to still figure out is the Event List block (list_this_week template) shows each day as a separate line. How do I get it to group shows by date? I assume there needs to be a conditional statement when the array is created to check for duplicate dates and then group them?

Here is the code from the template:
<?php  
        if (count($eArray) > 0) {
            foreach ($eArray as $date_string => $event) {
                extract($eventify->getEventListVars($event));
                //###################################################################################//
                //here we lay out they way the page looks, html with all our vars fed to it        //
                //this is the content that displays.  it is recommended not to edit anything beyond  //
                //the content parse.  Feel free to structure and re-arrange any element and adjust   //
                //CSS as desired.                              //
                //###################################################################################//
                ?>
                <div class="smallcal">
                    <div class="calwrap">
                       <!--<div class="img">-->
                      <div class="day"><h4>


Oh, and one last question. When I change 'M' for the month output to 'F' nothing displays. Why would this happen?

Thanks,
Choppie