I would love to see a mod that automatically creates a link to a Yahoo or Mapquest map based on address field(s) in an event.
Since most of our events are not necessarily in the same place, this would be quite helpful to site visitors!
First, you need to create fields in the event database called address, city, state, and zip.
Then, simply add the following code to default.html in the Event View section immediately after the <% } %> tag:
<TR><TD colspan="2" ALIGN="center" VALIGN="top"><SPAN CLASS="text"><B><a href="http://www.mapquest.com/maps/map.adp?city=<%= $EVENT->{'details'}->{'city'} %>&state=<%= $EVENT->{'details'}->{'state'} %>&address=<%= $EVENT->{'details'}->{'address'} %>&zip=<%= $EVENT->{'details'}->{'zip'} %>&zoom=8" target="_blank">Click here for a map and directions</a></SPAN></TD></TR>
This will pop open a second window with the Mapquest map for your event's address.
Enjoy!
Avi FrierVisionBurst.com
------------------ScottCalendarScript.com
All you actually need are the street addr and zip code fields.... so add those fields to your events, and then edit your template (or maybe this fits a pug-in now, I dunno yet)...
I added to my event-only view, I suppose you can add anywhere you'd like... my events already had a "location" field (ie. at Bob's house, at the hockey rink, etc)..
code:foreach $field (@$fields) { next unless ($db->{'properties'}->{$field}->{'display_details'}); # next if ($db->{'properties'}->{$field}->{'name'} eq "Zip"); # next if ($db->{'properties'}->{$field}->{'name'} eq "Street Addr"); %> <TR><TD ALIGN="right" VALIGN="top"><SPAN CLASS="text"><B><%=$db->{'properties'}->{$field}->{'name'}%>: </B></SPAN></TD> <TD ALIGN="left" VALIGN="top"><SPAN CLASS="text"><%=$EVENT->{details}->{$field}%> <% if (($db->{'properties'}->{$field}->{'name'} eq "Location") && ($EVENT->{'details'}->{'zip'}) && ($EVENT->{'details'}->{'streetaddr'}) ){ $EVENT->{'details'}->{'streetaddrurl'} = $EVENT->{'details'}->{'streetaddr'}; $EVENT->{'details'}->{'streetaddrurl'} =~ s/\s/\+/g; %><!-- MAP --> (<a href="http://mapquest.com/maps/map.adp?country=US&address=<%=$EVENT->{'details'}->{'streetaddrurl'}%>&zipcode=<%=$EVENT->{'details'}->{'zip'}%>&homesubmit.x =29&homesubmit.y=7">map</a> ) <% } %> </SPAN></TD></TR> <% } %>
foreach $field (@$fields) { next unless ($db->{'properties'}->{$field}->{'display_details'}); # next if ($db->{'properties'}->{$field}->{'name'} eq "Zip"); # next if ($db->{'properties'}->{$field}->{'name'} eq "Street Addr"); %> <TR><TD ALIGN="right" VALIGN="top"><SPAN CLASS="text"><B><%=$db->{'properties'}->{$field}->{'name'}%>: </B></SPAN></TD> <TD ALIGN="left" VALIGN="top"><SPAN CLASS="text"><%=$EVENT->{details}->{$field}%> <% if (($db->{'properties'}->{$field}->{'name'} eq "Location") && ($EVENT->{'details'}->{'zip'}) && ($EVENT->{'details'}->{'streetaddr'}) ){ $EVENT->{'details'}->{'streetaddrurl'} = $EVENT->{'details'}->{'streetaddr'}; $EVENT->{'details'}->{'streetaddrurl'} =~ s/\s/\+/g; %><!-- MAP --> (<a href="http://mapquest.com/maps/map.adp?country=US&address=<%=$EVENT->{'details'}->{'streetaddrurl'}%>&zipcode=<%=$EVENT->{'details'}->{'zip'}%>&homesubmit.x =29&homesubmit.y=7">map</a> ) <% } %> </SPAN></TD></TR> <% } %>
<% } %>
such an event can be seen at http://www.raleighjaycees.org/cgi-bin/cal3.pl?view=Event&event_id=2
For mapquest, the street addr can also be "Main and 1st" to find an intersection. Note that what displays for humans to see (spaces), must be replaced with "+" for mapquest.
Cheers,Mike
------------------
Realized that adding the if... href statement to the list view (I only had it on single event view) made a lot of sense too.
Mike
The first solution will most likely fail if there are any spaces in the address. If I'm reading the second solution correctly, you would only need three extra event fields:
"location" - a text description of the location. i.e. "At Bob's house." The Display Name of this field must be "Location" (capital L) for the changes to work.
"zip" - the zip code.
"streetaddr" - the street address.
These are the Unique ID's for the fields. Location should be the only one marked as "View in Event Details." All three should be marked as "View in Add Form."
------------------David Whittaker http://www.uabcm.com/ http://www.csworkbench.com/
So you do need the additional 3 custom fields for my hack (and a hack is what I consider it without more prettying up). Although really you could do away with location, and keep addr/zip hidden and just diplay a "product" field, that being the link to mapquest.
You should be able to "test" your link by hovering over it and seeing what it says...
it should resemble... http://mapquest.blah.blah?country=US&address=111+main_st&zipcode=12345&homesubmit.x=29&homesubmit.y=7
You can also speicify city and state if you already have that info in your calendar, but those fields are redundant to the zip code, so I didn't add them since I had no other need for them.
Step 1... add location, streetaddr and zip to your calendar.. make them visible, and see if you can display that data
Step 2... add the product link in (the if statement)
Random thought to puzzle over: since I am calling event_detail.html to display the events, is it possible that the variables are not being passed to the new window??? Is there some sort of mass-include that I need to do in the code for event_detail.html??? Just a thought that could be totally wrong...
ERROR PROCESSING TEMPLATEThere was an error in your template file. Below is the template file and also the perl code generated from it to help you with debugging.
Unmatched right curly bracket at (eval 1) line 292, at end of line syntax error at (eval 1) line 292, near ";}"
You can view the entire error at the following URL: http://www.vr6.com/calendar_error.html
Thanks,Ty
What we'de need to see would be the raw code from the template file. Cut and paste 10-15 lines of the code before and after the line the error occurs on (pointing the error line out) and we'll try to spot any errors.
Going by the error message, I'd be looking for an Unmatched right curly bracket or one there that shouldn't be. Maybe it's suppose to be a regular bracket ) or an > and not an }
Dan O.
[This message has been edited by DanO (edited January 23, 2003).]