Knowledge Base - Gateway for K2

 

What is it

K2 is a powerfull alternative to using the default article system in Joomla! with a rich set of 'out-of-the-box' features.

Using Geocode Factory's gateway plugin you can associate one or more sets of coordinates to each of your K2 articles. In this way you can display the locations of your K2 articles as markers on a map.


 

K2 Preparation

To geocode your K2 items using the Geocode Factory K2 gateway plugin you have a few options.

1
To get location data from your K2 custom fields.

    a) These can be either address fields like street, postcode, city, etc.

    b) Or they can be coordinate fields (latitude and longitude).

2
To get the coordinate data from the 3rd party extension "StyleWare K2 Google Maps".

 

If you use the "StyleWare K2 Google Maps" plugin you can skip the K2 preparation

 

K2 Custom Fields

k2 xtra fields

If you use K2 custom fields follow the following steps to create the fields before configuring the K2 gateway plugin:

Once inside your K2 component, click on the "Extra Fields" option from the left sidebar.

Then click on the "New" button from the top of the screen.

new extra field

In this tutorial we will be using address fields for street, postal code, city and country. If you choose to use coordinates fields instead, the process is very similar but you only need to create two fields in this case: latitude and longitude.

 

First custom field: Street

 1st extra field

Name: Give a name to your field.

Group: Choose the "Create new group" option and enter a name for your new group, ex: "Location Fields"

Required: Select the "Required" settings as you like.

Type: In our case the field type is a simple text field.

Finally, save your new field.

 

 

Second custom field: Postcode

2nd extra field

Name: Give a name to your field.

Group: Select the group you created in the previous step, in the 1st custom field, ex: "Location Fields".

Required: Select the "Required" settings as you like.

Type: In our case the field type is a simple text field.

Finally, save your new field and repeat this last step for as many fields as you like (ex: city, state, country, etc).

If you chose to use the coordinate fields of latitude and longitude you are done at this point.

 

 

k2 cat menuK2 Field Group Assignment

The K2 component allows you to assign different custom field groups to different categories. This gives us extra flexibility as each category can have it's own set(s) of custom fields.

So the final step of the K2 preparation is to assign the custom field group you created (ex:"Location Fields") to the category or categories you want to use it with. 

 

Once inside your K2 component, click on the "Categories" option from the left sidebar.

Then click on the category you wish to assign the new field group.

 

associate k2 cat

Select your custom fields group in the Associated "Extra Fields Group" option like in the image above and save. Repeat this for every category of K2 items you wish to use the same group of fields to geocode.

In our demo there is only one category

k2 cat associated

 K2 is now ready!


Installation

Overview

Note: In order to use Geocode Factory's K2 gateway plugin, you need to have Geocode Factory 5 component already installed, as well as the content gateway plugin (for Joomla content).

The content gateway plugin is included in your Geocode Factory 5 package by default (it is free).

 

  • plg_geofactory_gw_j30.zip: Joomla gateway plugin

 

The gateway plugin for K2 is not included in your Geocode Factory 5 package by default. This file is an optional extra:

  • plg_geofactory_gw_k2.zip: K2 gateway plugin

 

Access, Download and Installation

Both the K2 Gateway plugin file "plg_geofactory_gw_k2.zip" and the Joomla content gateway plugin file "plg_geofactory_gw_j30.zip" are installed using the standard Joomla installer

Please read the Download, install and update manual for more information.

 


Gateway Plugin configuration

Inside the joomla “Plugin Manager” you will find the Gateway plugins you installed. To locate them more easily, you can use the filter by adding the text “geocode” for example, like in the following image. You should see the following two plugins at least.

 joomla plugin manager

Geocode Factory - Joomla Gateway plugin

You do not need to configure anything in this plugin. The only thing is to make sure it is published (published by default).

 

Geocode Factory - K2 Gateway plugin

Configuring the K2 Gateway plugin you have the following options:

k2 gateway plugin

Colors of the lines between owners and content markers: If you choose to use the "Draw Lines" option (Specific Settings tab in Markerset manager) of Geocode Factory for the K2 gateway plugin, you can configure the color of the lines drawn between the markers here. To do so click on the hexadecimal color code and select the color from the palette pop-up. Or alternatively, you can type in the hexadecimal color code of your choice in the field directly.

Default avatar image: Optionally, you can select a default avatar image here for profiles without an image. If left empty the default Google pin will be used in this case.

Location fields group: Select the custom fields group you created in the previous step, the K2 preparation section (There is also an option to use custom fields from multiple groups. To do this you need to enable the 'All fields' option in component settings).

Used pattern: Select the default pattern for K2. A default pattern is created automatically when you install the plugin.

Silent geocode: Define if yes or no, the article is geocoded when the save button is clicked.


Pattern manager and K2 items

When you enter the pattern manager you will see that one default pattern for K2 items was created automatically when you installed the plugin.

k2 pattern manager

Click on the "Default - K2 pattern" and go to the third tab "Assign fields to the values".

 

k2 pattern

 

As we mentioned before you have three options available to geocode your K2 items using the Geocode Factory K2 gateway plugin. 

 

To geocode your K2 items using the Geocode Factory K2 gateway plugin you have these options.

1
To get location data from your K2 custom fields.

    a) These can be either address fields like street, postcode, city, etc.

    b) Or they can be coordinate fields (latitude and longitude).

2
To get the coordinate data from the 3rd party extension "StyleWare K2 Google Maps".

 

1- a) Location data from your K2 custom address fields

  • for the Latitude and Longitude options select " I have no coordinates fields (automatic)" 
  • for the address fields select the K2 custom fields you have created for each.

Like in the following image

pattern k2 fields 1

1- b) Location data from your K2 custom coordinate fields

  • for the Latitude and Longitude options select the custom fields you have created for each
  • leave the address fields below empty

Like in the following image

custom lat-long fields

 

 

2-) Coordinate data from the 3rd party extension "StyleWare K2 Google Maps"

  • for the Latitude and Longitude options select the "I have the optional swMap plugin enabled" for each
  • leave the address fields below these empty

 


 

Markerset

The specific settings tab

The options on this tab are generated based on the currently selected pattern. In this tab you can select various different filters for the current markerset allowing you to further customize your data pool. You may also select some other options which are not filter-related.

 k2 specific settings tab

 

Filter Generator: Here you can introduce SQL queries to filter out your results. The Geocode Factory query will be build with your optional filter. For instance, in the example above the condition is that the data in the field "k2_listme" has to be equal to "Yes". This way, the K2 entries which meet this condition will be used only. The idea in this case is to have a checkbox field (k2_listme) where the owners choose whether they want to have their entry displayed on the map "Yes", or not "No". Of course this field could be an administrative one instead, it's up to you and what you want to achieve.

Warning: The use of this feature is the most common source of errors that result in no markerset being displayed! Remember that here you are adding a clause/condition affecting the mysql database query. Each wrong or missing charter/quote will cause an error. Handle with care!

Categories to include: Here you can select the categories from which to choose the article markers to display on the map. You can enter many K2 categories.

Include child: Here you can select if you want to include items from child categories.

Entries to load: Choose the status of the items to display, ex: published.

Lines owners entries-events: Select if you wish to Draw Lines between the markers of the owners (authors) of the K2 items and their articles.

Enable Auto-Category: With the auto-category feature enabled, the markers that will be displayed will be items belonging to the categories you are currently browsing only (and child categories as well). This option is used to get a functionality typically seen in directories.

 

 

Applies To

Geocode Factory 5