A couple of months ago, I created a tutorial on the implementation of eventsCalendar2, which you can read here:
https://forums.modx.com/thread/74010/eventscalendar2---a-quick-tutorial#dis-post-410742
In that tutorial, I mentioned that I had taken the component a little bit further by adding a listing of a certain number of calendar events and having them appear on a side column within the site. It's been since requested that I show how I did that and I thought others might benefit, so I've created this little added tutorial.
If you would like to see what I'm talking about, there is a site that, as of this writing, is being developed where I've implemented it. You can see the calendar implemented on this page:
http://67.222.24.164/~hawkresort/calendar-holiday-seasonal-events/
...and a sample of the listing on any number of pages, for instance this one:
http://67.222.24.164/~hawkresort/special-packages.html
(see right hand column).
I won't rehash the calendar implementation again, please refer to the above linked tutorial, however, once it is up and running, you can list the events this way:
First, note that the listing is based on Shaun McCormick's blog tutorial, which you can refer to here:
http://rtfm.modx.com/display/revolution20/Creating+a+Blog+in+MODx+Revolution
For this implementation, you won't need all the components installed that Shaun's blog requires...really only getResources and Archivist. I haven't tried to run it without Archivist but I assume this implementation needs it to run (I installed it in the above-named site because it has a blog and Archivist is required for that). You can experiment whether it needs it or not on your own. getResources, however, is a must.
So, you download and install those components. Then, what I did was:
1. created a chunk called calendarEventsPosts (call yours whatever you wish but make sure you use the proper name in step 2 below). In it, add this code:
<a href="[[~[[+id]]]]" class="calendar_events_side_column_title">[[+pagetitle]]</a>
<p>[[+introtext:limit=`400`]]</p>
<p><span class="links">
<a href="[[~[[+id]]]]" class="readmore">Read more</a>
| <span class="date">Event on [[+tv.event_date:strtotime:date=`%b %d, %Y`]]</span>
</span></p>
Pretty straightforward, that code is the template the listing uses, but a couple things to note: first is that you can limit the number of characters that appear in the main part of the listing, in this case, to 400 characters. That's the 'limit=`400` part (backticks...not single quotes). Also, notice the date part. It takes that from the event_date TV I had created (see earlier tutorial) and the date format in this case gives you the result of that date, in the Month, Day, Year format. You can add or subtract elements from that template as you like...nothing is an absolute must for it to work; just a good starting point.
2. Made a chunk called calendarEventsPosts_code. In it, I added this code:
<div id="calendar_events_posts_pos">
[[!getResourcesTag?
&elementClass=`modSnippet`
&element=`getResources`
&tpl=`calendarEventsPosts`
&parents=`76`
&limit=`5`
&includeContent=`1`
&includeTVs=`1`
&processTVs=`1`
&showHidden=`1`
&hideContainers=`1`
&cache=`0`
&pageVarKey=`page`
&sortbyTV=`event_date`
&sortdirTV=`ASC`
]]
</div><!--calendar_events_posts_pos -->
The css I'll leave up to you, of course.
3. I added the calendarEventsPosts_code chunk to the individual pages to make it show up. You can put it straight in the template or add it, page-by-page, by way of a TV or any of your favorite methods.
Other notes:
&parents=`76` refers to same container (76 is the ID in the case of my site) that holds the calendar events resources.
The &limit=`5` refers to the number of events that will show up in the listing (backticks...not single quotes).
&tpl=`calendarEventsPosts` refers to the name of the chunk you created above. Name as you wish but make sure you refer to the correct name.
Normally, the code, as tutorialized in Shaun's blog tutorial would have the events show up most recent first, then the next oldest one one, etc. In this case, I wanted the events to show up with reverse order. To reverse the order they show up, I added the part:
&sortbyTV=`event_date`
&sortdirTV=`ASC`
To sort the other way, use DESC instead of ASC.
The `event_date` is the name of the TV I created in the previous tutorial that takes date of the event. Please refer to that.
While doing my own research, this part:
came up and I added it to the code, although I confess that I'm not sure what it is for, or if it is absolutely necessary. Please test on your own and let me know if it is just worthless in this case.
Really, that should do it. Hope it helps someone out there.
[ed. note: waizen last edited this post 14 years, 4 months ago.]