[Solved] products module & cggooglemaps

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

[Solved] products module & cggooglemaps

Post 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?
Last edited by ukmgranger on Thu Jul 29, 2010 12:34 pm, edited 1 time in total.
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: products module & cggooglemaps

Post 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?
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.
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: products module & cggooglemaps

Post 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!! :)
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: products module & cggooglemaps

Post 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"}
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.
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: products module & cggooglemaps

Post 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?!?
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: products module & cggooglemaps

Post 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.
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.
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: products module & cggooglemaps

Post 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}
Last edited by ukmgranger on Thu Jul 29, 2010 9:49 am, edited 1 time in total.
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: products module & cggooglemaps

Post 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?
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: products module & cggooglemaps

Post 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}
Last edited by ukmgranger on Thu Jul 29, 2010 12:41 pm, edited 1 time in total.
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: [Solved] products module & cggooglemaps

Post by tyman00 »

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.
Post Reply

Return to “Modules/Add-Ons”