[Solved] products module & cggooglemaps
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
[Solved] products module & cggooglemaps
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?
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?
Last edited by ukmgranger on Thu Jul 29, 2010 12:34 pm, edited 1 time in total.
Re: products module & cggooglemaps
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?
Have you considered using CompanyDirectory instead of Products?
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
Re: products module & cggooglemaps
Thanks for the info!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?
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
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"}
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
Re: products module & cggooglemaps
Well that is a great starting point!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"}
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
Yes, you should be able to do something like:
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.
Code: Select all
{foreach foo="bar" blah="entry"}
{cggm_add_dynpoint address=$entry->fields.postcode->value}
{/foreach}
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
Re: products module & cggooglemaps
Okay - been playing for a while and still no gravy!tyman00 wrote: Yes, you should be able to do something like:
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.Code: Select all
{foreach foo="bar" blah="entry"} {cggm_add_dynpoint address=$entry->fields.postcode->value} {/foreach}
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}
Last edited by ukmgranger on Thu Jul 29, 2010 9:49 am, edited 1 time in total.
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
Re: products module & cggooglemaps
Almost there! I have the map working for 'most' of the products.
My Products summary template is now:
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?
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}
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?
-
- Forum Members
- Posts: 72
- Joined: Wed Apr 04, 2007 9:54 am
Re: products module & cggooglemaps
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}
Last edited by ukmgranger on Thu Jul 29, 2010 12:41 pm, edited 1 time in total.
Re: [Solved] products module & cggooglemaps
Looks good to me. Good job walking yourself through it.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.