Joomy.net - Vytvoříme Vám web! Internetový marketing.

Úterý, 20 Červenec 2010 13:25

Special Tab for map fields

After successful installation of K2 Google Maps plugin there are extra fields in Plugins Tab in item edit form:

This text is a step by step manual how to get special Map Tab in item edit form:

First file mod

administrator/components/com_k2/views/item/view.html.php

Find rows around #293

 
  $K2PluginsItemOther=$dispatcher->trigger('onRenderAdminForm', array (&$item, 'item', 'other' ) );
  $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
 
  $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'item.xml');
  $form->loadINI($item->params);
  $this->assignRef('form', $form);
 
 

.. and add 2 lines, so the final code is

 
  $K2PluginsItemOther=$dispatcher->trigger('onRenderAdminForm', array (&$item, 'item', 'other' ) );
  $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
 
  $K2PluginsItemGMap=$dispatcher->trigger('onRenderAdminForm', array (&$item, 'item', 'gmap' ) );
  $this->assignRef('K2PluginsItemGMap', $K2PluginsItemGMap);
 
  $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'item.xml');
  $form->loadINI($item->params);
  $this->assignRef('form', $form);
 
 

Second file

administrator/components/com_k2/views/item/tmpl/default.php

Find lines #247-259

 
<!-- Tabs start here -->
<div class="simpleTabs">
 <ul class="simpleTabsNavigation">
   <li id="tabContent"><a href="#"><?php echo JText::_('Content'); ?></a></li>
   <li id="tabImage"><a href="#"><?php echo JText::_('Image'); ?></a></li>
   <li id="tabImageGallery"><a href="#"><?php echo JText::_('Image gallery'); ?></a></li>
   <li id="tabVideo"><a href="#"><?php echo JText::_('Video'); ?></a></li>
   <li id="tabExtraFields"><a href="#"><?php echo JText::_('Extra fields'); ?></a></li>
   <li id="tabAttachments"><a href="#"><?php echo JText::_('Attachments'); ?></a></li>
   <?php if(count(array_filter($this->K2PluginsItemOther))): ?>
   <li id="tabPlugins"><a href="#"><?php echo JText::_('Plugins'); ?></a></li>
   <?php endif; ?>
 </ul>
 

.. and add 1 line, so the final code is

 
<!-- Tabs start here -->
<div class="simpleTabs">
 <ul class="simpleTabsNavigation">
   <li id="tabContent"><a href="#"><?php echo JText::_('Content'); ?></a></li>
   <li id="tabImage"><a href="#"><?php echo JText::_('Image'); ?></a></li>
   <li id="tabImageGallery"><a href="#"><?php echo JText::_('Image gallery'); ?></a></li>
   <li id="tabVideo"><a href="#"><?php echo JText::_('Video'); ?></a></li>
   <li id="tabExtraFields"><a href="#"><?php echo JText::_('Extra fields'); ?></a></li>
   <li id="tabAttachments"><a href="#"><?php echo JText::_('Attachments'); ?></a></li>
   <li id="tabGMap"><a href="#"><?php echo JText::_('Map'); ?></a></li>
   <?php if(count(array_filter($this->K2PluginsItemOther))): ?>
   <li id="tabPlugins"><a href="#"><?php echo JText::_('Plugins'); ?></a></li>
   <?php endif; ?>
 </ul>
 

then, in the same file find lines #593-594

 
 <?php if(count(array_filter($this->K2PluginsItemOther))): ?>
 <!-- Tab other plugins -->
 

.. and before these add few lines, so the final code is

 
 <!-- Tab gMap -->
 <div class="simpleTabsContent">
    <div class="itemPlugins">
      <?php foreach ($this->K2PluginsItemGMap as $K2Plugin) : ?>
      <?php if(!is_null($K2Plugin)): ?>
      <fieldset>
        <legend><?php echo $K2Plugin->name; ?></legend>
        <?php echo $K2Plugin->fields; ?>
      </fieldset>
      <?php endif; ?>
      <?php endforeach; ?>
    </div>
 </div>
 
 <?php if(count(array_filter($this->K2PluginsItemOther))): ?>
 <!-- Tab other plugins -->
 

Third file - CSS

administrator/components/com_k2/css/k2.css

Add style to css file, line #235

 
ul.simpleTabsNavigation li#tabGMap a {background-image: url('/../images/editforms/Map.png');}
 

and upload an icon for the tab

administrator/components/com_k2/images/editforms/Map.png

Category edit form

In very similiar way you can modify files for category edit form:

Download

Download all modified files in following ZIP package, extract with complete directory structure and after back-up of original files, upload to your server.

K2 version 2.3!, also changed files with special Tab in category edit form included.

Published in K2 Plugin
Pátek, 16 Červenec 2010 14:12

K2 Google Maps plugin

Version: 1.0
The plugin adds some additional fields in K2 backend for item, category and user. In K2 frontend it display Google Map with selected marker on position of respective item, etc.
Appearence of the Google Map highly customizable by plugin parameters.

Download

Showcases

Standard map with no controls

Zoom/Pan Controls = None
Google Maps Type Buttons = No
Map Type on Start = Normal
Show Overview Map = No

Standard map

Satellite map with small controls and overview

Zoom/Pan Controls = Small Maps Control
Google Maps Type Buttons = No
Map Type on Start = Satellite
Show Overview Map = Yes

Standard map

Terrain map with large controls

Zoom/Pan Controls = Large Maps Control
Google Maps Type Buttons = Yes
Map Type on Start = Terrain
Show Overview Map = No

Standard map

TO DO (next version if some donations)

  • Add global parameters for dimensions and offset of marker image and shadow image
  • Possibility to show Wikipedia (info) and Panoramio (photos) layer in the map
  • Reading GEO information from KML file - most probably linked to Attachments field
  • Add 3D zoom and pan map controls option (like maps.google.com)
  • More professional output for "Bubble" (marker info).

Useful sources

Please, support further development

Published in K2 Plugin