cfalzone ||

Subscribe (?) Subscribe to RSS

Posts Tagged ‘DotCMS’

Creating an iCal Feed from DotCMS Content / Calendar

Published on September 16th, 2009 in 3 Comments »

First off I apologize for be a slacker and not having time to post anything on this blog for quite some time. I’d like to say that I’m going to get better at it, but I probably won’t!

This past week I needed to get an iCal feed created for my DotCMS Calendar.  What I came up with might not be the most elegant solution, but it does the trick for Outlook and Google Calendars at least.  So I thought I’d post up my process …

First I started by creating an HTML page in DotCMS, and choosing the Blank Template.  The next thing I did was create a new contentlet.  The important thing to remember about this step is to name your contentlet something that is going to be ewasy to remember.  The reason for this is that doing this will break the DotCMS Page Editor.  You’ll see why a little latter.

Now for the code:

$response.setContentType('text/calendar')
$response.setHeader("Content-disposition","attachment;filename=calendar.ics")
#set($today = $UtilMethods.now())
#set($fromDate = $date.format("MM/dd/yyyy", $today))
#set($endDate = $UtilMethods.addDays($today, 30))
#set($toDate = $date.format("MM/dd/yyyy", $endDate))
#pullContent("+structureInode:135155  +date1:[01/01/1900 00:00:00
TO $toDate 23:59:59] +date2:[$fromDate 00:00:00 TO 01/01/3000 00:00:00]
+languageId:1 +deleted:false +live:true" '0' 'date1')
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
CALSCALE:GREGORIAN
X-WR-TIMEZONE:America/New_York
X-WR-CALNAME:EUP Events
BEGIN:VTIMEZONE
TZID:US-Eastern
LAST-MODIFIED:19870101T000000Z
BEGIN:STANDARD
DTSTART:19971026T020000
RDATE:19971026T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19971026T020000
RDATE:19970406T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE
#foreach($content in $list)
BEGIN:VEVENT
DTSTAMP:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTSTART:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTEND:$date.format("yyyyMMdd'T'HHmmss", $content.endDate)
SUMMARY:$!content.title
UID:$!content.identifier
PRIORITY:3
CATEGORIES:MEETING
LOCATION:Edinboro
END:VEVENT
#end
END:VCALENDAR

Let me pick this apart section by section. First off we have what I like to call, “The Magic” of this whole thing:

$response.setContentType('text/calendar')
$response.setHeader("Content-disposition","attachment;filename=calendar.ics")

What this little bit of code does is set content type for the page, and tells the browser that this should be downloaded, not displayed in the screen. It also tells the browser exactly what the filename should be that they are downloading. This allows us to set the extension of .ics.

#set($today = $UtilMethods.now())
#set($fromDate = $date.format("MM/dd/yyyy", $today))
#set($endDate = $UtilMethods.addDays($today, 30))
#set($toDate = $date.format("MM/dd/yyyy", $endDate))
#pullContent("+structureInode:135155  +date1:[01/01/1900 00:00:00
TO $toDate 23:59:59] +date2:[$fromDate 00:00:00 TO 01/01/3000 00:00:00]
+languageId:1 +deleted:false +live:true" '0' 'date1')

Note:  I had to break up the #pullContent into 3 lines so it would fit on the page, this should be one line.

This bit of code is probably fairly familiar to most of you reading this. Basically it is pulling the events from the last 30 days. You will of course need to make sure you change the structureInode to match what your Event Structure’s Inode is.

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
CALSCALE:GREGORIAN
X-WR-TIMEZONE:America/New_York
X-WR-CALNAME:EUP Events
BEGIN:VTIMEZONE
TZID:US-Eastern
LAST-MODIFIED:19870101T000000Z
BEGIN:STANDARD
DTSTART:19971026T020000
RDATE:19971026T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19971026T020000
RDATE:19970406T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE

This is the begining of the iCal Code. It defines the Time Zone, the name, the version, and various other tidbits. I found it was necessary to put in the vTimeZone element for the calendar to show up in Google in the right times. I also found a nifty reference of the iCal Format Here.

#foreach($content in $list)
BEGIN:VEVENT
DTSTAMP:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTSTART:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTEND:$date.format("yyyyMMdd'T'HHmmss", $content.endDate)
SUMMARY:$!content.title
UID:$!content.identifier
PRIORITY:3
CATEGORIES:MEETING
LOCATION:Edinboro
END:VEVENT
#end
END:VCALENDAR

The rest of the code is fairly straight foward I think. Loop through each contentlet and create a vEvent item then bookend with your ending vCalendar. The hard part is the Time Format. I found putting in the Timezone here did not work in Google, perhaps you will have better luck.

Now, I know this isn’t perfect. I haven’t put in descriptions and nice locations and all that. This was a quick and dirty write-up to get what I needed done. I hope it benefits you, if you have any questions or suggestions I’d love to hear from you in the comments.

Where to go from here? I would love to see this macroized and/or wigitized and put into a plugin. I hope some day I have time to beef it up and learn more about what I can and can’t do with iCal. I would also like to put in the ability to give iCal Feeds for specific categories and tags. Ultimately, I would like to see the iCal download servelet that already exists in DotCMS fleshed out to this natively within the CMS.

Please if you have any suggestions on how to make this better or any improvements you’ve made on this, I’d love to hear about it in the comments.

DotCMS Bootcamp

Published on February 11th, 2009 in No Comments »

Last week saw me in Miami at the DotCMS Open Minds Conference, Boot Camp.  DotMarketing’s approach to the conference this year was slightly different this year.  The focus was more on Training whereas last year was more like demo.  I’d have to say that I really enjoyed the conference.

Tuesday, Feb 3

My journey to Miami started a day before the conference.  I couldn’t get a flight in the day of the conference.  It was fairly uneventful (that’s good!).  The Hotel this year was the Mayfair.  A little more ritzy than the Sonata, but still very nice.  I ended up eating at the Johnny Rockets.

Wednesday, Feb 4

The conference didn’t officially start until the registration/welcome party at 6PM.  Since I was there quite early I decided to jump over to DotMarketing Headquarters about 1PM.  DotMarketing was nice enough to throw us Jason Tesser for some informal pre-conference training.

We talked a lot about the bits and pieces of DotCMS.  Here are some take-aways from that conversation:

  • Lucene queries will no longer require the live, deleted, and language parameters.  The DotCMS code tries to be smart enough to put those in based on where you are in the system.  This should simplify the lucene quries in our code considerably.
  • DotMarketing plans on hitting the Content Browser Search functionality with a hammer very soon.  They want to add a more intuitive search.  The idea is to make the search much more like a Google search.  A very simple one field search with advanced option and more intuitive operators.
  • They removed multicast traffic in clustering.  This is coming in the next version, but it is a major improvement on the way clustering works.  At Edinboro I decided to nix the cluster because of the multicast issues on campus.

After the informal training we went back to the Hotel for the opening party.  I got to meet back up with Fienen and meet some of the new folks from the DotCMS Community.  A big welcome to IPFW who just made the decision to go with DotCMS and had a considerable force at the conference.  After the party we (Jason, Fienen, and some others) headed to the Knife for dinner.  The Knife was a very nice place to eat.  It is an Argentinian Steak House Buffet kinda thing.  Very Nice!

After dinner I had mega troubles with my laptop’s wireless.  So that’s why this post is coming a little late.

Thursday, Feb 5

Thursday started with breakfast at the Bookstore in the Grove.  The first session of the day was on structures and relationships.  I already knew much of the content here, but for the new guys this was a lot of bricks and mortar kind of training on the Back-End of DotCMS.  I did manage to grab a couple morsels of goodness from the session though:

  • Relationships have an order field but in order to get the #PullRelatedContent macro to sort on that field you have to first save the order in the back-end.  Then, if you leave the sort parameter blank your results will be sorted by that field.  This is something I had been wondering how to do for some time now.
  • You can also pass a lucene query to the macro.  Allowing you to drill down the results to just what you need.  I couldn’t think of an immediate use for this, but I’ll tuck it away for a rainy day.

The rest of the day, I spent with Jason Tesser in a one-on-one session.  This is the true value of the DotCMS conference.  I am really happy to see a company that will give you one-on-one attention.  Jason and I talked a lot about the nuts and bolts of the Content API and DotConnect Java Classes.  I learned how to use the DotConnect Class to retrieve SQL results from my server and then use the Content API to update and insert new content into DotCMS structures.  Very, very valuable stuff.

After the show a few of had a specialized training on administration of DotCMS.  We learned that you can use JMX to debug some of the more interesting problems may run into with cache and other things in the system.  It looked like really cool stuff, but it was a bit over my head.  Andres did a great job of showing us what can can’t be done though.

I ended up going with a rather large group to a sushi place for dinner.  I am not overly obsessed with sushi, but I went along and the place we went to was very nice.  I had a fried shrimp/lettuce/rice roll that was actually very good.

Friday, Feb 6

Breakfast was at the bookstore again.  We started the day off with Plugins Training.  The training was very well laid out and was my main target for the conference.  Jason covered a ton of information about what you can do with plugins and how they work.  I wish there was more actual code, but when you are talking to a large audience that kind of thing would’ve been hard to pull off. I can’t say how stoked I am about the addition of plugins to the DotCMS product.

One of the cool things you can do with plugins is move all your configuration and custom macros out of DotCMS.  This way if you ever need to restore a server or do an upgrade, you can just stick your plugin back in and you are essentially up and running.  I plan on doing this as my first plugin and hope to have a good post about how it’s all done.  That is, or corse, if Fienen doesn’t beat me to it ;)

The last half of the day was on Ajax.  While I was not overly interested in the ajax stuff, it was interesting to see some of the cool stuff that DotCMS can do there.

After the Ajax session we moved into the Focus Group / Roadmap / Deiscuss / Wrapup portion of the conference.  I can’t tell you how impressed I am with the way DotCMS is developing.  Here is what is in store for us in the coming year:

  • Enterprise Offeringe -vs- Open Source Offerings:  The idea is is to not turn DotCMS into crippleware.  There are quite a few CMSs that go the crippleware route.  In other words, you can have the software for free, but to really get the most out of it you have to pay.  DotCMS is going pretty much the opposite route.  The open source product will always be fully featured.  (Actually, it will most likely be more featured than the Enterprise. )  The Enterprise version will be the hardened product with better supoprt.
  • Plugins, Plugins, Plugins:  Plugins give us a major shift in the way customization of DotCMS is handled.  From the simplest stuff like your configuration or a small macro, to the big stuff like new portlets.   Plugins also push forward community growth.  We hope to see the infamous DotCMSForge this year.  To add to this DotMarketing is also going to be putting on a plugin competition to get the community start on making plugins.
  • 1.7:  What was going to be 1.6.5c is now going to be 1.7.  With this version, slated to come out in the next few weeks, we will see the addition of plugins.  Also, as a first plugin DotMarketing has created Front Ent Content Submition.
  • 1.8: With 1.8 we will see fater releases (to the tune of 1 every 3-4 months).  1.8 will also add the concept of Binary Content.  This will allow us to dirrectly attach files to content along with exporters.  This esentially turns DotCMS into a digital asset / document management system.  Also due for 1.8 is drafting.  The idea is that it will work much like wordpress posts that auto-save or gmail messages.  There are also changed coming for content/page owners, which is something that has not worked as intended in DotCMS.  Lastly, it will add wiki-like link structures to DotCMS.
  • Looking beyond 1.8 there are some big plans for this year.  A simplified UI for permissions, improvements to the Multi-Site Hosting UI, Push Publishing, a better forms builder with chaining, and access to content in the CMS view web services over CMIS.

Wrap Up

So, this has been a really long congolomo-blog post.  Sorry for that.  As you can see the conference was a great source of information!  I thouroughly enjoyed myself and I think everyone that came got a ton of value out of it.  Not to mention the networking possibilities.    There are some really cool things in store for us this year.  To say that I am giddy with anticipation would be an understatement.

Here are some additional links to information about the conference (more as I find them):

Getting Started with Velocity in DotCMS

Published on August 14th, 2008 in No Comments »

I seem to get a lot of questions on how to start with velocity coding. What is available? What is the Syntax? I think it’s a good question so it’s time to write up a quick post about it.

First off, I would start with actually building your site. Come up with a need. Start with something simple and something that you already have data for. I found that trial and error on real problems is the best way for me to learn a new language.

Most likely, if you’re trying to do something simple, there is already an example of how to do it in DotCMS’s Demo Site. The username/password is: test@dotcms.org/test. Remeber to put a /c after the host to get to the login page. I’ve found that most of my questions can be answered just by looking a good example.

From there my next stop is the documentation that DotCMS has on velocity:

  1. Velocity and the dotCMS: This is a great file to find out what API’s or ViewTools that are avilable in your Velocity code. For example: If you wanted to use the EscapeTool, you would use the variable $esc in your code. I show you in a bit how to find out what is available in each tool.
  2. Velocity Cheat Sheet: This file has several nice examples on how to use the various Macros and ViewTools available in DotCMS. I find a lot of my answers about how to do something in DotCMS here.
  3. Macros Tips and Tricks: The nice thing about velocity coding is that you don’t really have to know how to do it to take advantage of it. That’s where macros come in to play. Macros take a whole ball of velocity code and wrap it up into one nice little line of code. (Just noting here that you can get some good examples of velocity coding in the macros file: /dotCMS/WEB-INF/velocity/*.vm)

If you really cannot find what you are looking for in that, the next step would be to look in the API docs. Now, if you’ve never looked at Javadocs before this might be a little overwhelming at first. But, I find it extremely useful when I am trying to do something out of the box. Browse to http://dotcms.org/api. From there scroll down the list and click on the “View Tools” class (com.dotmarketing.viewtools). From there you will get a list of all the api’s that DotMarketing has created.

That’s nice if what you want is a list of DotCMS’s View Tools, but if you are looking for the built in stuff, head over to Apache’s Velocity Site and click on the Tools link. From there click on Generic Tools and then the specific tool that want to look up.

I hope that helps to get new users up and going with velocity. If you still feel very confused, here is a lit of other resources that you might find handy:

Update: 1:12 PM, July 23, 2008:

Jim S. over in the DotCMS IRC group pointed out a velocity mailing list: http://www.nabble.com/Velocity—User-f347.html. Thanks Jim!

Also, that brings up a good point. We have a core group of DotCMS-er’s over in the #dotcms IRC chatroom. Feel free to jump on board and ask us your questions! We are on freenode.

Photos

Tweets ...

Posting tweet...

Powered by Twitter Tools