Log in

View Full Version : How best to place a calendar from one site on another site



kuau
10-14-2009, 11:06 AM
I created an events calendar on Website A that displays events from a database on that server. The webmaster of Website B has asked if he can place the mini-calendar from Website A on Website B so that it displays events from the database on Website A. I have an idea of how to do this but wondered if there were an easy way to do it without having to run my code on his server (or reinvent the wheel). I think widgets do this kind of thing but I do not know how to create a widget. Any ideas? Thanks.

bluewalrus
10-15-2009, 01:15 PM
Is the calender on it's on page and brought in through an include? If so an iframe to the original calender i think could do it. If a) it is not an include you could make it one if more people would want to use it; but i don't use iframes much and am not sure if this would work.

kuau
10-15-2009, 10:17 PM
The mini-calendar code is in an include inside another include, but the code includes a connection to the database, $GET_variables, and other variables, and it is just a corner of the homepage on Website A. I know how do do an iframe to create a window to the whole page but not just a specific section of a page. I looked at the DD Ajax scripts and they all seem to require the pages to be on the same domain. Nobody out there knows a simple way to do this? Thanks.

djr33
10-16-2009, 01:26 AM
You can use PHP includes if the calendar is static.
If there is ajax, dynamic refreshing or anything else complex like that, you won't have much luck, so it would be better to use an iframe.

iframes (and frames in general) are problematic, so it is best to avoid them, but that is the only way to be serving from two domains at once, which is what might need to happen if the calendar is more than a one-time load.

kuau
10-16-2009, 01:54 AM
Not sure what you mean by static. If you click on the days of the calendar, it displays the events for that day. And today's date is always highlighted. It might help if you see the actual calendar at http://www.calendarmaui.com/. The look of the calendar is pretty static, but "today" changes every day.

The guy from Maui Now wants the mini-calendar on his site so that when you click on a day on his calendar, it displays the list of events on the Calendar Maui site. He doesn't want to have to maintain his own database of events on his server (I don't blame him... no point in duplicating work). I could have sworn I have seen sites that work like this by just putting a code snippet on the remote site, like on a realtor's site or something. Isn't this a type of RSS feed? But I thought RSS feeds reformat the data as text (?). I hope that clarifies the issue somewhat. Mahalo!

djr33
10-16-2009, 03:32 AM
"Static" meaning it isn't doing stuff once the page is loaded. If it's loading content, moving around, etc., then it might require being on the same domain and just including it would cause some problems.
Based on the link it looks like it isn't doing anything too complex-- just links that reload the page. That should be fine.

The only question is whether the links on the calendar will work once it is transplanted on another page. Try it out and if that works, it should be fine in general.

kuau
10-16-2009, 04:13 AM
Thanks, Daniel. What I don't know how to do is create an iframe that includes only part of the page, ie. the mini-calendar. If you look at where the iframe will go in the right column on http://www.mauinow.com, you'll see what I mean. This is my best guess, but I think it would have to put the entire home page in the iframe.


<iframe width="251" height="288" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.calendarmaui.com/ output=embed"></iframe>
The original way I thought of to do this was to give the guy a modified version of my mini-calendar code to put on his page with the links spelled out with the full URL so that when someone clicked a day, it would go to Calendar Maui and display the events page for that day on Calendar Maui. I haven't tried this yet, in case there were an easier way. If I can get the iframe to display only the calendar, it seems that would be easier. What do you think?

djr33
10-16-2009, 05:09 AM
Ah, I see now why this is more complex.
Right, there is no way to just display part of the page in the iframe.

There are two ways to go about this, aside from just giving up and including the whole page:

1. You can grab the whole page and then strip everything out except the calendar.
2. You can separate the calendar first, then include it into both pages.

Pros/cons of both:
1. This is hard and maybe even unreliable. You can't do it with an iframe, but you could try with PHP to basically find the part of the html code where the calendar starts and then again where it ends, delete the remainder of the code (after you've store the entire page as a string), then you can display that part. It will be even more complex if you also need to include javascript or css elements from the <head> section of the calendar page, but you could do that manually in this case.
2. This basically means redesigning your first page to include the calendar just like the new page you're making. Start by creating a calendar only page, then include that (just include() in php) into the second page. Then you can use iframes or PHP, as you like, to include it into the other site. The real problem here is that it requires changing the other page, so that means you need no limits on doing so-- obviously for including other pages into your site this would be a problem, but it would probably be ok since you are designing both (right?).

I would recommend the second option, and start by just separating the calendar. Then see how include() works... if something gets weird with that, maybe try an iframe.