Product Module - Gallery

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
oakst
Forum Members
Forum Members
Posts: 21
Joined: Wed May 08, 2013 2:18 pm

Product Module - Gallery

Post by oakst »

I am following up on this post: http://forum.cmsmadesimple.org/viewtopi ... y+products

First, THANK YOU for showing us this and I am so close to figuring it out I can taste it.

What piece of code do I need to add to the product detail template to make the gallery functional for the custom drop down gallery field?

I have followed your instructions adding the textfield, module_custom/, get_gallery_dropdown, and revised editproduct.tpl. I am showing the dropdown in the product page and am now trying to add the actual gallery to my detail page.
Image

Here is the code I am attempting:

Code: Select all

{*trying to add gallery in the product detail template *}
{assign var='products' value=$mod}
<div class="ProductDirectoryItem">

{* note: {content} must be called before the hierarchy view is called *}
{if $entry->hierarchy_ > 0}{$active_hierarchy=$entry->hierarchy_}{/if}

{if is_array($entry->breadcrumb)}
Breadcrumb:  {' >> '|implode:$entry->breadcrumb}<br/>
{/if}



{* set a canonical url *}
{if $entry->detail_url != ''}{$canonical=$entry->detail_url}{/if}


{if $entry->details ne ''}
Details:<br />
{$entry->details}<br />
{/if}

{* uncomment the following line if the Promotions module is installed *}
{* promo_get_prod_discount product_=$entry-> assign='foo' *}
{if isset($foo.promo_)}
<span style="color: red;">Discount:  {$currency_symbol}{$foo.discount|number_format:2} ({$foo.percentage|number_format:2}%)</span><br/>
{if $entry->price ne ''}
Price {$currency_symbol}: {$entry->price * $foo.decimal|number_format:2}per sq.ft.<br />
{/if}
{elseif $entry->price ne ''}
Price {$currency_symbol}: {$entry->price}<br />
{/if}

{* accessing all of the fields in a list *}
{if isset($entry->fields) && count($entry->fields)}
 
  {foreach from=$entry->fields key='name' item='field'}
     <div class="product_detail_field"><p>
       {$name}:&nbsp;&nbsp;{$field->value}<br/>
       {if $field->type == 'image' && isset($field->thumbnail)}
        <a href="{$entry->file_location}/{$field->value}" target="_blank"> <img src="{$entry->file_location}/{$field->thumbnail}" /></a>
       {/if}
     </p></div>
  {/foreach}
{/if}

{* print out attributes *}
{if isset($entry->attributes)}
  <h4>Attributes</h4>
  <table>
    <thead>
      <tr>
        <th>Text</th>
        <th>Sku</th>
        <th>Adjustment</th>
      </tr>
    </thead>
    <tbody>
    {foreach from=$entry->attributes key='name' item='attrib'}
      <tr>
        <td>{$attrib.text}</td>
        <td>{$attrib.sku}</td>
        <td>{$attrib.adjustment}</td>
       </tr>
    {/foreach}
    </tbody>
  </table>
{/if}

{* print out the categories *}
{if isset($entry->categories)}
 
  {foreach from=$entry->categories item='category'}
    <div class="product_detail_category"><p>
      {* if there are data fields associated with this category, display them too *}
      {if isset($category->data) && count($category->data)}
        <div class="product_detail_category_fields">
        <strong>{$Products->Lang('data')}</strong><br/>
        {foreach from=$category->data item='onedataitem'}
           <div class="product_detail_category_onefield">
           {if $onedataitem.field_type == 'image'}
             <a href="{$category->file_location}/{$onedataitem.field_value}"><img src="{$category->file_location}/thumb_{$onedataitem.field_value}" alt="thumb" /></a>
[glow]             {elseif $onedataitem.field_type == 'gallery'}
             {gallery dir="{$onedataitem.field_value}"}[/glow]
           {elseif $onedataitem.field_type == 'file'}
             <a href="{$category->file_location}/{$onedataitem.field_value}">{$onedataitem.field_value}</a>
           {else}
              {$onedataitem.field_value}<br/>
			  Breadcrumb: {breadcrumbs}<br />
           {/if}
           </div>
        {/foreach}
        </div>
      {/if}
    </p></div>
  {/foreach}
{/if}

<div>
{* display the cart *}
{*Cart2 sku=$entry->sku*}
</div>

{* 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')}

</div>
This is the error I recieve when I add this code to my detail template:

Syntax error in template "module_db_tpl:Products;detail_sample2" on line 84 "{gallery dir="{$onedataitem.field_value}"}" unknown tag "gallery"

What I see when I remove the gallery portion in my code:

Image

Any help would be greatly appreciated. I am such a fan of this CMS.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Product Module - Gallery

Post by Dr.CSS »

Most times tags don't like { } in them, try {gallery dir="$onedataitem.field_value"} you may also need to use ' instead of "...
oakst
Forum Members
Forum Members
Posts: 21
Joined: Wed May 08, 2013 2:18 pm

Re: Product Module - Gallery

Post by oakst »

Hmmm...

I found one error. gallery should be Gallery, but it did not reflect the gallery I was hoping to see. Still shows me the same.

Image

But no Gallery :(

I have tried the code

Code: Select all

           {elseif $onedataitem.field_type == 'gallery'}
             {Gallery dir="$onedataitem.field_value"}
and

Code: Select all

           {elseif $onedataitem.field_type == 'gallery'}
             {Gallery dir="{$onedataitem.field_value}"}
(with and without the curly brackets)

How would I insert the instead of or do you have any other ideas how to make this work in the detail template? Thank you for you help!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Product Module - Gallery

Post by velden »

Are you sure you're using the right foreach loop of this template?
I guess not.
oakst
Forum Members
Forum Members
Posts: 21
Joined: Wed May 08, 2013 2:18 pm

Re: Product Module - Gallery

Post by oakst »

The foreach loop I was using was the one linked to the original detail template script.

Code: Select all

{foreach from=$category->data item='onedataitem'}
If this is incorrect, do you know the proper foreach loop to use?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Product Module - Gallery

Post by velden »

{foreach from=$entry->fields key='name' item='field'}
oakst
Forum Members
Forum Members
Posts: 21
Joined: Wed May 08, 2013 2:18 pm

Re: Product Module - Gallery

Post by oakst »

Thank you Velden!

However, I am still having issues...

Code: Select all

{* accessing all of the fields in a list *}
{if isset($entry->fields) && count($entry->fields)}
  {foreach from=$entry->fields key='name' item='field'}
     <div class="product_detail_field"><p>
       {$Products->Lang('name')}: {$name}&nbsp; &nbsp;
       {$Products->lang('value')}: {$field->value}<br/>
       {if $field->type == 'image' && isset($field->thumbnail)}
         <img src="{$entry->file_location}/{$field->thumbnail}" alt="{$field->value}"/>
           {elseif $field->type == 'gallery'}
             {Gallery dir="$field->value"}
       {/if}
     </p></div>
  {/foreach}
{/if}
Is there something special I need to do to the gallery? The loop is simply producing the field value and not the gallery itself.

I have tried this piece of code several ways:

Code: Select all

{Gallery dir='$field->value'}
{Gallery dir="{$field->value}"}
{Gallery dir='{$field->value}'}
Image

Also, I tried just adding the gallery into the details portion of the Product module's item to no avail. I tried under the details portion with the module_custom and with out the module_custom page, in case that was the conflict.

However, the Gallery does work on a separate test page:
http://midcitiesfloorsandmore.com/test

I am just not sure what I am missing here.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Product Module - Gallery

Post by velden »

Code: Select all

{elseif $field->type == 'gallery'}
Probably never renders true. I don't know the details of this setup. You need to learn how to debug such issues.

Start printing the contents of the field variable inside the loop:

Code: Select all

<pre>{$field|print_r}</pre>
BTW:

Code: Select all

{Gallery dir=$field->value}
should do.
oakst
Forum Members
Forum Members
Posts: 21
Joined: Wed May 08, 2013 2:18 pm

Re: Product Module - Gallery

Post by oakst »

I could kiss you! Leave it to me to make it too difficult. All I needed was

Code: Select all

{Gallery dir=$field->value}
Thank you, thank you, THANK YOU!
Post Reply

Return to “Modules/Add-Ons”