Page 1 of 1
[Solved] products module & cggooglemaps
Posted: Wed Jul 28, 2010 9:17 am
by ukmgranger
Hi all,
I am using the Products module as company database. in this I have set up a user defined field (postcode) which I want to display in cggooglemaps. Is this possible?
What I actually want to do is display all the products (read that campsites) on the map.
Is there a way to dynamically add multiple postcodes to the map?
Re: products module & cggooglemaps
Posted: Wed Jul 28, 2010 4:04 pm
by tyman00
Check out the "Add Dynamic" point tag in the CGGoogleMaps help. The dynamic point tag was actually added for use in a situation very similar to this, only used in CompanyDirectory.
Have you considered using CompanyDirectory instead of Products?
Re: products module & cggooglemaps
Posted: Wed Jul 28, 2010 4:13 pm
by ukmgranger
tyman00 wrote:
Check out the "Add Dynamic" point tag in the CGGoogleMaps help. The dynamic point tag was actually added for use in a situation very similar to this, only used in CompanyDirectory.
Have you considered using CompanyDirectory instead of Products?
Thanks for the info!
I saw the add point tag in the help file, but I don't really know what to do with it?!?
To switch to Company directory now would be a bit of a PITA as I have got about 60 companies in the products module and don't really fancy swapping them over and re-creating templates again.
Besides, I'm sure that it is not going to be too difficult to get maps working with it with the help of you lovely people on this forum!!

Re: products module & cggooglemaps
Posted: Wed Jul 28, 2010 4:16 pm
by tyman00
I have a Products installation for listing homes for sale. I needed the exact location so I am using Latitude and Longitude. I have two custom fields each named accordingly. Here is how it looks in my detail template:
Code: Select all
{cggm_add_dynpoint long=$entry->fields.Longitude->value lat=$entry->fields.Latitude->value icon="9"}
Re: products module & cggooglemaps
Posted: Wed Jul 28, 2010 4:26 pm
by ukmgranger
tyman00 wrote:
I have a Products installation for listing homes for sale. I needed the exact location so I am using Latitude and Longitude. I have two custom fields each named accordingly. Here is how it looks in my detail template:
Code: Select all
{cggm_add_dynpoint long=$entry->fields.Longitude->value lat=$entry->fields.Latitude->value icon="9"}
Well that is a great starting point!
Am I right in thinking that I can add 'Address' rather than lat long? I have a postcode for all the products stored in the products module.
I normally call this with {$entry->fields.postcode->value}.
What I also want to do is show all the products (campsites) on one map, so I'm guessing that there needs to be a foreach statement in there?!?
Re: products module & cggooglemaps
Posted: Wed Jul 28, 2010 4:31 pm
by tyman00
Yes, you should be able to do something like:
Code: Select all
{foreach foo="bar" blah="entry"}
{cggm_add_dynpoint address=$entry->fields.postcode->value}
{/foreach}
You'll have to do this in a summary template and I can't remember the exact syntax off the top of my head so your mileage may vary.
Re: products module & cggooglemaps
Posted: Thu Jul 29, 2010 9:45 am
by ukmgranger
tyman00 wrote:
Yes, you should be able to do something like:
Code: Select all
{foreach foo="bar" blah="entry"}
{cggm_add_dynpoint address=$entry->fields.postcode->value}
{/foreach}
You'll have to do this in a summary template and I can't remember the exact syntax off the top of my head so your mileage may vary.
Okay - been playing for a while and still no gravy!
This is my summary template. How would I get the map in here to display all the postcodes?
Code: Select all
{if isset($catformstart)}
{$catformstart}
{$catdropdown}{$catbutton}
{$catformend}
{/if}
{$firstlink} {$prevlink} {$pagetext} {$curpage} {$oftext} {$pagecount} {$nextlink} {$lastlink}
<div id="productsTitles">
<div id="product_name">
<p>Campsite Name</p>
</div>
<div id="product_town">
<p>Nearest Town</p>
</div>
<div id="product_area">
<p>Area</p>
</div>
</div>
{foreach from=$items item=entry}
<div class="ProductDirectoryItem">
<ul>
<li class="p_name"> <a href="{$entry->detail_url}">{$entry->product_name}</a></li>
<li class="p_tel">{$entry->fields.Location->value}</li>
<li class="p_area">{foreach from=$entry->categories item='category'}{$category->name}{$hierarchy_item.name}{/foreach}</li>
</ul>
<div class="listingBottom">
</div>
</div>
{/foreach}
Re: products module & cggooglemaps
Posted: Thu Jul 29, 2010 11:01 am
by ukmgranger
Almost there! I have the map working for 'most' of the products.
My Products summary template is now:
Code: Select all
{if isset($catformstart)}
{$catformstart}
{$catdropdown}{$catbutton}
{$catformend}
{/if}
{$firstlink} {$prevlink} {$pagetext} {$curpage} {$oftext} {$pagecount} {$nextlink} {$lastlink}
{CGGoogleMaps map=map1}
{foreach from=$items item=entry}
<div class="ProductDirectoryItem">
<ul>
<li class="p_name"> <a href="{$entry->detail_url}">{$entry->product_name}</a></li>
<li class="p_location">{$entry->fields.Location->value}</li>
<li class="p_area">{foreach from=$entry->categories item='category'}{$category->name}, {$hierarchy_item.name}{/foreach}</li>
<li class="p_tel">{$entry->fields.Telephone->value}</li>
</ul>
{cggm_add_dynpoint map=map1 name=$entry->product_name address=$entry->fields.postcode->value}
<div class="listingBottom">
</div>
</div>
{/foreach}
{CGGoogleMaps map=map1}
Next Problem:
What I now need to do is add both address and postcode fields along with ',UK' so that it can accurately find the address.
$entry->fields.address->value $entry->fields.postcode->value ,UK
Any ideas how to do this?
Re: products module & cggooglemaps
Posted: Thu Jul 29, 2010 12:34 pm
by ukmgranger
okay - final code that I am relatively happy with (This is a summary template for the Products module):
Code: Select all
{if isset($catformstart)}
{$catformstart}
{$catdropdown}{$catbutton}
{$catformend}
{/if}
{$firstlink} {$prevlink} {$pagetext} {$curpage} {$oftext} {$pagecount} {$nextlink} {$lastlink}
{foreach from=$items item=entry}
<div class="ProductDirectoryItem">
<ul>
<li class="p_name"> <a href="{$entry->detail_url}">{$entry->product_name}</a></li>
<li class="p_location">{$entry->fields.Location->value}</li>
<li class="p_area">{foreach from=$entry->categories item='category'}{$category->name}, {$hierarchy_item.name}{/foreach}</li>
<li class="p_tel">{$entry->fields.Telephone->value}</li>
</ul>
{capture assign='description'}
<a href="{$entry->detail_url}">{$entry->product_name}</a></br>
<p>{$entry->fields.Address->value}
{$entry->fields.postcode->value}<br />
<strong>{$entry->fields.Telephone->value}</Strong></p>
{/capture}
{capture assign='addressFull'}
{$entry->fields.postcode->value},uk
{/capture}
{cggm_add_dynpoint map=map1 name=$entry->product_name address=$addressFull description=$description}
<div class="listingBottom">
</div>
</div>
{/foreach}
{CGGoogleMaps map=map1}
Re: [Solved] products module & cggooglemaps
Posted: Thu Jul 29, 2010 2:34 pm
by tyman00
Looks good to me. Good job walking yourself through it.