Page 1 of 1

[solved]Products Module - Add Gallery and Google Maps to Detail PageForEachItem

Posted: Thu Aug 26, 2010 11:24 pm
by kkreitz
I am using the Products module for a rental listing site. I have it styled and laid out how I would like and thought I was home free! In looking at the module I thought I could create two custom fields, one for the photo gallery and one for CGGoogleMaps. I thought that when adding an item I could go to each specific custom field's input box and place tags such as:

{Gallery dir='unit1'}

and

{cggm_add_dynpoint map="1" name="anything" lat="34.440584" long="-119.73527" icon="house"}
{CGGoogleMaps map='1'}

and I would have exactly what I wanted. Unfortunately it seems this does not work that way.

Am I missing something simple? Or is there an entirely different way to do this? And if so how complicated?

Thank You.

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 7:53 am
by maranc
If you want include gallery photos in product template plase make it as bellow:

1. Create custom field in products (type textbox ex. name 'foto_dir')
2. In gallery module create your subgallery, named ex. 'product1' and put hier your photos
2. Return to products module, edit product and in field foto_dir write value 'product1' (this is a path to dir in gallery).
3. In product template call gallery like this:

{if $field->name == 'foto_dir'}
    {if $field->value != ""}
               
                    {Gallery dir=$field->value}
               
  {else}No photos for this products  <-- optional when there isn't any photo
    {/if}
{/if}

More... The same method you can use for making pagelimit for photos (definied field in products module, not in gallery template)


Best regrads
Marek A.

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 8:38 am
by uniqu3
I didn't do this in Products module but had the same task and i used news module.

First i created a custom field named googlemap, this is where i simply enter address with postal code.
{capture assign='addressFull'}
{$entry->fieldsbyname.googlemap->value}
{/capture}
{cggm_add_dynpoint map="1" name=$entry->title|cms_escape:htmlall address=$addressFull}
{CGGoogleMaps map="1"}
map= is the id of the map you want to use for these entries
name= you should change this to work with products module
address= is the captured value of my extra field googlemap

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 7:03 pm
by kkreitz
Marek,

Thank you for your response and help, it is very much appreciated. Unfortunately I cannot seem to get it to work. I have followed the steps you suggested and put the additional code into the detail page of the products module. The div class "galleryArea" does not show up in the html source code at all. I checked and rechecked everything many times and nothing. ...here is the complete code for the detail page with your piece in it:


{assign var='products' value=$mod}


{$entry->product_name}


{if $field->name == 'foto_dir'}
    {if $field->value != ""}
               
                    {Gallery dir=$field->value}
               
  {else}No photos for this products 
    {/if}
{/if}

{if isset($foo.promo_id)}
Discount:  {$currency_symbol}{$foo.discount|number_format:2} ({$foo.percentage|number_format:2}%)
{if $entry->price ne ''}
Rent {$currency_symbol}: {$entry->price * $foo.decimal|number_format:2}

{/if}
{elseif $entry->price ne ''}
Rent: {$currency_symbol}{$entry->price}

{/if}

{if $entry->details ne ''}
{$entry->details}
{/if}

{* accessing all of the fields in a list *}
{if count($entry->fields)}
  {foreach from=$entry->fields key='name' item='field'}
   
      {$name}:
      {$field->value}
 
   
  {/foreach}
{/if}

{* print out attributes *}
{if isset($entry->attributes)}
  Attributes
  {foreach from=$entry->attributes key='name' item='attribset'}
    {$name}
   
      {foreach from=$attribset key='label' item='adjustment'}
        {$label}: {$adjustment}
      {/foreach}
   
  {/foreach}
{/if}

{* print out the categories *}
{if isset($entry->categories)}
  Categories
  {foreach from=$entry->categories item='category'}
   
      {$mod->Lang('id')}: {$category->id}
      {$mod->Lang('name')}: {$category->name}
      {* if there are data fields associated with this category, display them too *}
      {if isset($category->data) && count($category->data)}
       
        {$mod->Lang('data')}
        {foreach from=$category->data item='onedataitem'}
         
          {if $onedataitem.field_type == 'image'}
            file_location}/{$onedataitem.field_value}">file_location}/thumb_{$onedataitem.field_value}" alt="thumb" />
          {elseif $onedataitem.field_type == 'file'}
            file_location}/{$onedataitem.field_value}">{$onedataitem.field_value}
          {else}
            {$onedataitem.field_prompt}: {$onedataitem.field_value}
          {/if}
         
        {/foreach}
       
      {/if}
   
  {/foreach}
{/if}


{* create a link back to the top of the page *}
{anchor anchor='product_name' text=$products->Lang('return_to_top') title=$products->Lang('return_to_top')}


Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 7:19 pm
by maranc
This fragment must be above code, witch call Gallery module:

{if count($entry->fields)}
  {foreach from=$entry->fields key='name' item='field'}
  {/foreach}
{/if}


I'm not expert in smarty, but I thing it will be working when you call this above.

Marek A.

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 7:52 pm
by kkreitz
This worked with one small change!

Instead of:
2. Return to products module, edit product and in field foto_dir write value 'product1' (this is a path to dir in gallery)

I removed the quotes in entering the value
2. Return to products module, edit product and in field foto_dir write value product1 (this is a path to dir in gallery)

Thank You!

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 8:11 pm
by kkreitz
Here is the code for the Gallery Module:


{if count($entry->fields)}
  {foreach from=$entry->fields key='name' item='field'}
   
      {if $field->name == 'foto_dir'}
      {if $field->value != ""}
               
                    {Gallery dir=$field->value}
               
  {else}No photos for this products 
  {/foreach}
{/if}


Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Fri Aug 27, 2010 9:06 pm
by kkreitz
uniqu3,

Thank you for your help on this item. I have followed your steps and put the code into the detail page just below the custom fields code. The Google map that I want to use shows up, however the details of the dynapoint map do not  :-[

Here is the code I put into the detail page:

{* accessing all of the fields in a list *}
{if count($entry->fields)}
 {foreach from=$entry->fields key='name' item='field'}
   
      {$name}:
      {$field->value}  
   
 {/foreach}
{/if}

{capture assign='addressFull'}
{$entry->fieldsbyname.googlemap->value}
{/capture}
{cggm_add_dynpoint map="1" name=$entry->product_name address=$addressFull}
{CGGoogleMaps map="1"}

In the html is the following error message from Google Maps:


Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Sat Aug 28, 2010 8:19 am
by uniqu3
Hi kkreitz,

this is the code i tested with products module and is working:
{cggm_add_dynpoint name=$entry->product_name map="1" address=$entry->fields.googlemap->value}
{CGGoogleMaps map="1"}
See: http://demo.i-arts.eu/Products/1/121/Test

Re: Products Module - Add Gallery and Google Maps to Detail Page for each item

Posted: Sat Aug 28, 2010 10:43 am
by kkreitz
Yes it is working! Thank you!!