We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Please ask all support in this thread:

    http://www.modxcms.com/forums/index.php?topic=11681

    Please use the version in the repository as it is the most up to date version.

    http://www.modxcms.com/Google-Events-1301.html

    Moderators, if possible, can this be merged with the official support thread>

    Alright you Crazy ModXers,

    I have another snippet in development that is at a stage releasable for some general consumption. This snippet will allow you to grab the events you have stored in a publicly shared Google Calendar from the current date to an arbitrarily set amount of days out.

    This version supports templates for the first row, the even rows, the odd rows, and the last row.

    It supports using CURL by default, and if your server doesn’t support it, it will fall back to fopen. Redundancy, sweet.

    Also, this new version supports getting the link to the Google Event page!

    Further, I took doze’s recommendations and added the ability to skip a certain amount of events and limit the total events outputted.

    As you can see this script now supports a tiny sidebar style calendar and a bigger full fledged calendar. However it can be fully skinned with CSS! Yay! Now you can use the Google Calendar as your back end and not be restricted to their layout, colors, or whatnot!

    And finally, if you find any bugs, have suggestions, or want to improve my code, feel free!

    *UPDATE*
    So there were some bugs with the [+where+] placeholder. So I implemented simplepie to do the RSS reading. I imagine this will be more efficient than my code. This code will no longer support recurring events. They are more trouble than they are worth, at least with my time, to figure out. If someone else wants to pick up the ball here, feel free.

    Also, if anyone wants to add a better calendar class, or integrate this with the Kalender snippet, feel free. I basically just chose the first one I found :-D.

    As always, feel free to report bugs, make suggestions, or just improve my code by yourself.

    After a few days I will post this to the repository.

    *UPDATE* 1/22/2007
    I added some cleaner error handling to avoid MODx Parse errors in case the feed address is empty, incorrect, or the google server is down.

    *UPDATE* 2/1/2007
    The raw feed that Google produces added "amp;" to the end of HTML entities so if you typed the character "&" in your description, you would get "&" in the raw code of your feed, so it would display "&" on the final output. So GoogleEvents will now strip "&," "'amp;," and "&quote;amp;," and replace them with "&," "'," and "&quote," respectively. These are the most common HTML entities that I saw that were producing problems, and it seems to work rather well.

    Also, I removed the hard coded "border" attribute in the "<img>" tag so that it passes as XHTML Strict.
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 14050
      • 788 Posts
      Just so you know. There is a bug when someone leaves the title of the event blank. It will be fixed in the next release. Also, anyone more knowledgeable than me (pretty much everyone here) care to elaborate on how to make this snippet easy to template by the user through chunks? I tried looking at how Ditto takes a Chunk for templating, but am horribly confused.
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 15987
        • 786 Posts
        jester here is how you will want to template it:

        have a parameter that takes the name of a chunk: &template=`myChunk`

        this chunk will need to have some placholders in it to output the information typically these are something like [+eventdate+], [+eventtitle+], etc...

        Now in your code you will nedd to get the chunk specified from the parameter using the Modx api: $modx->getChunk($template)

        you can put this in a conditional so that you can have a defualt layout

        $userTemplate = $modx->getChunk($template)
        if (!$userTemplate) {
          $userTemplate = '<div>[+eventtitle+}</div>';
        }
        


        Then for each event you are outputting use str_replace to insert the correct data into the placeholders.

        Hope that helps, I use a similar method in both Wayfinder & the FileDownlaod snippet if you want to give them a look over.
          • 14050
          • 788 Posts
          Thanks Kyle. I was finally able to get the templating to work. I have uploaded the newest Beta, GoogleEvents-BETA2. This beta is basically a complete rewrite from the first. If you even looked at the first you will see that there is hardly anything in common with it. It is amazing that I am trying to learn from existing PHP Scripts and adapt them to ModX, and by the time I am done, I have a completely different script. A new feature to this beta besides the ease of templating is also the ability to list your items in chronological or reverse chronological order. This beta also allows you to pass parameters in the snippet call including your template ("tpl"), email address ("email"), and the chronological order ("order").

          If any of you have suggestions on making this script more feature rich, suggestions for performances gains, or would like to take it and run with it, feel free!

          An example of the new templated version can be seen here:

          http://www.fredsbarn.com/sandbox/modx/index.php?id=47

          To download the script, check the first post!
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 15987
            • 786 Posts
            one nice feature when making lists like this is to set a class for alternating events so that you can have alternating background colors or something like that. Maybe having a first and last class would be nice too. Looks like a great snippet though. I already see a use for it on one of my sites.

            Thanks,
            Kyle
              • 7923
              • 4,213 Posts
              Quote from: kylej at Nov 04, 2006, 04:44 AM

              one nice feature when making lists like this is to set a class for alternating events so that you can have alternating background colors or something like that. Maybe having a first and last class would be nice too. Looks like a great snippet though. I already see a use for it on one of my sites.
              Even better would be to have those in different templates, tplOddRow, tplEvenRow, tplFirstRow, tplLastRow. That way, users can for example display more info about the next upcoming events and other type of list from the others.. Also some parameter to skip certain number of events from the start of the list would be good. So users can have two snippet calls to achieve something like this: first call lists the next 6 events with some layout and second call has parameter to skip the first 6 and list others beyond that using some other layout.

              Great snippet btw!


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 14050
                • 788 Posts
                What great ideas. Sounds like it shouldn’t be too hard to implement. But then I always say that until I get into it to get my hands dirty. I would also like to be able to output in some calendar format for a main page and a sidebar, but that is a little further off (still on the radar though). I think it would be nice to have an ajax Calendar that can be filled with the data that my snippet grabs.
                  Jesse R.
                  Consider trying something new and extraordinary.
                  Illinois Wine

                  Have you considered donating to MODx lately?
                  Donate now. Every contribution helps.
                  • 14050
                  • 788 Posts
                  Per request, I made even, odd, first, and last templateable. Also you can still just pass a general template as I had before. Check the readme for the newest info. I figured this was enough of a feature boost to bump it up to 1.1 smiley Check the first post of the thread for the download and the demo link. I also plan in making some more things available in parameter calls, including doze’s suggestion for skipping a certain number of events.

                  As always, any bugs should be reported here, along with feature requests for this snippet.
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                    • 15987
                    • 786 Posts
                    Very nice smiley At some point you will want to add this into the repository.

                    Great work
                      • 14050
                      • 788 Posts
                      I plan on it. However, I wanted to elaborate on the documentation some more and make sure everything that is configurable can be passed as a parameter. Nothing too difficult, I just always drag my feet when it comes to documentation :-D

                      Also, I was going to wait until a few more downloads and see if I got any bug reports before I didn’t call it beta code anymore.
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.