More flexible theming for KML placemarks
| Project: | KML module |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Image teasers are a bit odd... the $item->teaser built for display in placemark popups do not include the actual thumb, even though by default thumbnails are shown in teasers around a Drupal site. This must be because the theming of image nodes looks after this some how.
By the same token one could probably make a theme function to do this for the kml_placemark_description type. However, a simple way to include thumbs from image nodes is to have the kml_format_placemark function do this for us.
Just a few lines need to be added in that function as shown here:
function kml_format_placemark($item, $link, $alt = 0, $args = array()) {
$title = $item->title;
$description = $item->teaser;
/* Special case for images */
if ($item->type == 'image') {
$description = $item->content['image']['#value'] . $description;
}I don't really agree with this module needing to treat images in a special way, but unless the image module is modified to include thumbs in the $item->teaser is there another way?

#1
Ahhhhh... a better fix for this would be something more generic that allowed more control via the theme functions.
If one changed the
theme_kml_placemark_descriptionfunction so that instead of taking the raw text description, one passed the whole node object things would be a lot more flexible.Default code would become:
function kml_format_placemark($item, $link, $alt = 0, $args = array()) {
$title = $item->title;
$output = " <Placemark>\n"
.' <name>'. check_plain($title) ."</name>\n"
." <description><![CDATA[\n". theme('kml_placemark_description', $item, $link) ."\n]]></description>\n"
. " <styleUrl>$stylemap</styleUrl>\n";
...
}
...
...
function theme_kml_placemark_description($item, $link) {
$output = check_markup($item->teaser);
$output .= '<br/><a href="'. check_url($link) .'">'. t('View page') .'</a>';
return $output;
}
At first glance this doesn't seem particularly useful, but it allows one to place a function like this in their
template.phpfile:function phptemplate_kml_placemark_description($node, $link) {
if ($node->type == 'foo') {
/* Do something specific just for this content type */
$description = format_foo_for_kml($node);
} elseif ($node->type == 'image') {
/* The image fix previously mentioned */
$description = $node->teaser . $node->content['image']['#value'];
} else {
$description = $node->teaser;
}
$output = check_markup($description);
/* Note we remove the link to the content. Not very useful, but shows flexibility */
return $output;
}
#2
Here's a patch file. It's been tested with the latest KML.module (5.x-1.x-dev (2007-Nov-20))
I'm really keen to see this incorporated into the base code. It's such a simple change but allows a lot of flexibility.
Particularly nice when combined with #82725: Allow for icons in GE to be altered (per c.type).
Thanks.
#3
Patch now committed to cvs.
#4
Automatically closed -- issue fixed for two weeks with no activity.