How To Add Google Maps To Your Review Site

CUSTOMIZING TEMPLATES -- Red Queen Tutorial 08

Adjust Text:  a a a a
« Red Queen User Manual   |   Tutorial Table Of Contents   |   Obtain Red Queen »


CUSTOMIZING TEMPLATES

Templates

Overall, the inclusion of Google Maps related templates is just a bit more complicated that for other features in the program. This is because the content of some parsed templates needs to appear in the section of the navigation template, while other sections need to go near the closing tag. Furthermore, the content of these templates is largely javascript--make one small mistake and your Google Map disappears, leaving you wondering where the error might be. For this reason, it is not recommended that you perform more than the minimum possible modifications to the templates that go into putting a Google Map on the page.

All Template Toolkit templates that deal with Google Maps are have a common file naming format. They start with the prefix gmaps_ and can be found with all the other templates used to create public pages.

The templates that you are most likely to want to edit are the ones that determine what information from a thing record should appear in the popup window that appears when the visitor runs their mouse over a location marker. These are the "tooltip" templates, since Google refers to this popup element as a tooltip:

gmaps_tooltip_item.ttml
gmaps_tooltip_member.ttml
gmaps_tooltip_supplier.ttml

Fortunately there is NO javascript in any of these 3 templates. So if you need to adjust what appears in the popup window for a business that is represented in a map, you will want to edit the gmaps_tooltip_supplier.ttml template. In it you will find some HTML formatting for a single table that contains information for a record from the Supplier table.

In addition to the formatting for a thumnailed image, you might find a table row that contains something like the following:

[% comma = '' %]
[% newline = '' %]
[%- IF supplier.contact_phone %][% comma = ', ' %][% newline %][% newline = '
' %]<b>[% supplier.contact_phone %]</b>[% END %] [%- IF supplier.addr_street %][% comma = ', ' %][% newline %][% newline = '
' %][% supplier.addr_street %][% END %] [%- IF supplier.addr_city %][% comma = ', ' %][% newline %][% newline = '
' %][% supplier.addr_city %][% END %] [%- IF supplier.addr_zipcode %][% comma %][% supplier.addr_zipcode %][% END -%]

This is very straightforward. All the code does is check for the existence of a few fields, and, if found, a separate line is added to the table cell to display that piece of information. You would use something similar in the tooltip template for the Item or Member table.

If you can restrict your editing of the Google Maps templates to the few lines in the relevant table row shown above, you will be doing yourself a big favor. Ambitious editing is likely only to cause you a good deal of headaches when your Google Map mysteriously disappears.

Note:You will also find the following line in the template, which reformats the entire content of the template so that it may be written safely as a piece of javascript. So, do NOT alter this line:

[%- html = html FILTER replace("\n\r?","'\n+'") -%]

« Table of Contents


Copyright © 2004 Random Mouse Software. All Rights Reserved.