Jump to content


[Snippet] calSnippet


  • You cannot reply to this topic
29 replies to this topic

#1 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 19 March 2007 - 04:06 PM

File Name: calSnippet
File Submitter: Oliver
File Submitted: 19 Mar 2007
File Updated: 28 Mar 2007
File Category: Calendars & Events

I'm trying to submit my calendar snippet to the library. I think this is the right way to do that.

An example of the snippet can be viewed here. Features include:
  • Can pull events from multiple folders
  • Uses the description field to determine event dates
  • Displays a monthly calendar view with event details below it
  • Each event links to a page describing it
  • No configuration necessary to use, but it's easy for advanced users to use custom CSS, custom forward/backward arrow images, etc.
  • Can use weblinks to have a single Etomite page appear on the calendar multiple times.
Let me know if you need any more information.

Click here to download this file

#2 Toni

    Etomite Forum Newbie

  • Member
  • 7 posts

Posted 21 March 2007 - 06:10 AM

I think, the problem of non-local strings (in non-english instalations) like march, may is caused by the date-function.

If i put the following init:
setlocale (LC_TIME, "de_DE");

and instead of date(...)
strftime(...)

I got local german strings back: März, Mai

CU
Toni

Edited by Toni, 21 March 2007 - 06:11 AM.


#3 Toni

    Etomite Forum Newbie

  • Member
  • 7 posts

Posted 22 March 2007 - 10:42 AM

@Oliver

do you want to get the modified code?

Now it works perfect on one of my (german) websites.

CU
Toni

Edited by Toni, 22 March 2007 - 10:42 AM.


#4 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 22 March 2007 - 01:28 PM

G'day,

Have you thought about adapting this snippet to produce markup that is compatible with the hCalendar microformat?

See http://microformats.org/wiki/hcalendar

Best Regards, Lloyd Borrett.

#5 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 26 March 2007 - 03:04 PM

Toni:

Yes, please send me the code and I'll look at what it would take to add it to the snippet.

-- Oliver

#6 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 26 March 2007 - 03:05 PM

Lloyd:

I hadn't heard of hCalendar, but I just looked it up and it seems really cool. I haven't given it a careful look yet so I don't really know what would be involved in making the hCalendar compatible, but I'll definitely consider it.

Thanks for the tip,
Oliver

#7 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 26 March 2007 - 09:43 PM

Hey,
I found a little problem while trying to get this to validate, it looks like a few of the style variables aren't showing properly (see bold)

<div class = "calTitle"><a $calPrevLinkStyle href="http://www.
and
...s = "calMonth">March, 2007</span> <a $calNextLinkStyle href="http://www.

Other than that problem (which is beyond my abilities to solve,) all I have to do to get this to validate to xhtml transitional is to change "&" to "&" in the URL's.

#8 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 26 March 2007 - 09:48 PM

View Postcathode, on Mar 26 2007, 05:43 PM, said:

Hey,
I found a little problem while trying to get this to validate, it looks like a few of the style variables aren't showing properly (see bold)

<div class = "calTitle"><a $calPrevLinkStyle href="http://www.
and
...s = "calMonth">March, 2007</span> <a $calNextLinkStyle href="http://www.

Other than that problem (which is beyond my abilities to solve,) all I have to do to get this to validate to xhtml transitional is to change "&" to "&" in the URL's.

I forgot to add: This is with the style sheet section un commented and the inline style section deleted.

#9 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 26 March 2007 - 10:03 PM

View Postcathode, on Mar 26 2007, 05:48 PM, said:

I forgot to add: This is with the style sheet section un commented and the inline style section deleted.

I just realized that this does not do a date range - i.e. "2007-03-27 - 2007-03-29"

That limits it's use rather heavily..

#10 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 27 March 2007 - 12:32 AM

View Postcathode, on Mar 26 2007, 02:43 PM, said:

Hey,
I found a little problem while trying to get this to validate, it looks like a few of the style variables aren't showing properly (see bold)

<div class = "calTitle"><a $calPrevLinkStyle href="http://www.
and
...s = "calMonth">March, 2007</span> <a $calNextLinkStyle href="http://www.

Other than that problem (which is beyond my abilities to solve,) all I have to do to get this to validate to xhtml transitional is to change "&" to "&" in the URL's.

Could you either attach the HTML that etomite generates or point me to a page that has the non-validating code? What kind of validation errors are you getting?

Thanks,
Oliver

#11 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 27 March 2007 - 12:39 AM

View Postcathode, on Mar 26 2007, 03:03 PM, said:

I just realized that this does not do a date range - i.e. "2007-03-27 - 2007-03-29"

That limits it's use rather heavily..

Yes, you can't do this :( I may add it eventually, but it's actually a bit tricky since the DB wants to treat the description as a string and there's no way to associate a date with a document. That means you can't ask the DB to grab any events that contain the current date efficiently. In real use it's probably not a big concern to just grab all documents with a date less than the 1st of the next month and filter them myself, but I don't like the idea of releasing code that will slow down as people add more and more events and don't delete the old ones.

In the meantime, you can use weblinks to have one event appear on several days. Just create a weblink for each day and give each link a different description. Not as handy as a full date range I realize, but better than having to create multiple identical copies of the same document.

#12 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 02:33 AM

View PostOliver, on Mar 26 2007, 08:32 PM, said:

Could you either attach the HTML that etomite generates or point me to a page that has the non-validating code? What kind of validation errors are you getting?

Thanks,
Oliver

Well, the problem is obvious., as I have said in my other post, you can't have $something within an anchor tag.

Anyhow, I found the problem, you used single quotes instead of double quotes, your variables weren't parsing. Here's the fix:
$ret .= "<a $calPrevLinkStyle href='" . $prevURL . "'>" . $leftArrow . "</a> ";
$ret .= "<a $calNextLinkStyle href='" . $nextURL. "'>" . $rightArrow . "</a> ";

Edited by cathode, 27 March 2007 - 02:34 AM.


#13 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 02:41 AM

View PostOliver, on Mar 26 2007, 08:39 PM, said:

Yes, you can't do this :( I may add it eventually, but it's actually a bit tricky since the DB wants to treat the description as a string and there's no way to associate a date with a document. That means you can't ask the DB to grab any events that contain the current date efficiently. In real use it's probably not a big concern to just grab all documents with a date less than the 1st of the next month and filter them myself, but I don't like the idea of releasing code that will slow down as people add more and more events and don't delete the old ones.

In the meantime, you can use weblinks to have one event appear on several days. Just create a weblink for each day and give each link a different description. Not as handy as a full date range I realize, but better than having to create multiple identical copies of the same document.

Etomite really needs a good quality, complete event calendar snippet. I'll pay someone to make one as soon as I can pass the development fee onto a client...

#14 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 03:40 AM

Another comment I have:
Why not make use of the title and long title, and save the document's description field for the date and time?

Then in the listing you could generate this:
<ul>
	<li>
		<h2>Event Title</h2> <!-- pulled from short title -->
		<h3>Event Long Title</h3> <!-- pulled from the long title -->
		<p>Date and Time</p> <!- - pulled from the description -->
	</li>
</ul>

It is my opinion that despite it's limitations, this is the best calendar/event snippet for Etomite, thanks for the great snippet. Unlike Events_Suite, this is easy to use, doesn't break, and doesn't make use of the alias for date information.

#15 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 02:25 PM

Here's my Calendar test page, I'm still working on trying to modify the output:
http://www.n-vent.com/calendar.html

#16 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 27 March 2007 - 04:00 PM

View Postcathode, on Mar 26 2007, 07:33 PM, said:

Well, the problem is obvious., as I have said in my other post, you can't have $something within an anchor tag.

Anyhow, I found the problem, you used single quotes instead of double quotes, your variables weren't parsing. Here's the fix:
$ret .= "<a $calPrevLinkStyle href='" . $prevURL . "'>" . $leftArrow . "</a> ";
$ret .= "<a $calNextLinkStyle href='" . $nextURL. "'>" . $rightArrow . "</a> ";

I see. I misunderstood the initial post. I thought that was source code, not HTML output you were including. I'll fix soon and update the snippet. Thanks for tracking this down.

One other question, that initial post also said:

Quote

all I have to do to get this to validate to xhtml transitional is to change "&" to "&" in the URL's.

I'm a bit confused by this. Both "&" and "&" look identical to me.

#17 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 04:21 PM

oops, sorry - like this: & a m p ; without spaces.

#18 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 27 March 2007 - 04:42 PM

View Postcathode, on Mar 27 2007, 12:21 PM, said:

oops, sorry - like this: & a m p ; without spaces.

Ive been trying to get the output to utilize the pagetitle and longtitle. I haven't figured it out yet. Should that be a simple change?

#19 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 28 March 2007 - 05:45 AM

Cathode:

Thanks for tracking down the bugs. I think I've got 'em fixed but my web server is down at the moment so I can't test. Will test soon and upload assuming there are no more bugs.

As for using pagetitle and longtitle: I can see why that would be useful. However, for my needs I think it's actually a drawback so I'm not sure about adding it to the snippet. Maybe I'll add it as an option (e.g. you could set a config variable that would say if these should be pulled or not).

In the meantime, if you want to use them and are motivated to fix things I think it should be relatively easy. The data is pulled in this line:

$eventDataRaw = $etomite->getIntTableRows("id, description" ,"site_content",  ...

the "id, description" part says what fields to pull out. Just add pagetitle and longtitle here to get them. You'd then have to update the buildEventArray function to use this data instead of grabbing everything out of the description field. The comments at the top of the buildEventArray function aren't great. I've updated them, and will check them in as soon as I can test things. In the meantime, this is, I think, a better comment:

/* Given a bunch of data from the DB (an array of events) reprocess to build an array of
   arrays with such that $eventData[$date] = an array of of events on $date. Each
   event in the array is represented as yet another array with keys "description", 
   "start", and "stop". The arrays for each day will be sorted by the "start" times
   of the events with events having no associated time coming first and having a start
   time of 0. */

If you were motivated to make all this work and have it optional to use the description field or a combination of fields that would be awesome and I'd be more than happy to add that to the snippet.

Good luck. Let me know if you have questions.

#20 Oliver

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 28 March 2007 - 04:15 PM

I was able to test the changes Cathode suggested and after validating added a few more. Also updated the comments. I've uploaded a newer version. You can get it here





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users