Page 1 of 1
Product Module - Gallery
Posted: Wed Mar 26, 2014 11:26 am
by przemo
Hi,
I would like the product page to post a photo
gallery. Has anyone used this module and has the solution?
Now I have only one image per page:
Code: Select all
{foreach from=$entry->fields key='name' item='field'}
{if $field->name == 'picture' && $field->value!=''}
<img src="{CGSmartImage src=$entry->file_location|cat:'/'|cat:$field->value filter_resize="c,240,150" noembed=1 notag=1}" alt="{$entry->title|escape:htmlall}" />
{/if}
Does anyone have an idea how to add more photos whithout creating several custom fields in template?
Is there a way to connect with {
Gallery} module?
I'm working on:
CMSMS (1.11.9)
CGSmartImage (1.16)
Products (2.20.2)
JQueryTools (1.2.6)
CGExtensions (.1.38.5)
Re: Product Module - Gallery
Posted: Wed Mar 26, 2014 2:14 pm
by zaidcrowe
I think this is the only way to achieve this - at least as far as I know, would love to hear if its doable.
If you dont need ecommerce functionality then Id use ListIt2 - but if you do, you might be stuck

Re: Product Module - Gallery
Posted: Thu Mar 27, 2014 1:22 am
by applejack
If you are using SKU codes which are unique then create a
Gallery directory based on that and call the
Gallery from within
Products.
Alternatively add another field to
Products and enter the
Gallery directory name.
For an example see
https://yanksair.com/Products/69/106/Gr ... cat-F6F-5/
You don't even need to upload the photos in the
Gallery module you can just FTP them.
Re: Product Module - Gallery
Posted: Thu Mar 27, 2014 8:43 am
by zaidcrowe
@applejack - smart!
Re: Product Module - Gallery
Posted: Thu Mar 27, 2014 10:32 am
by applejack
If you use a naming convention for things such as folders based upon say the page aliases then there is a lot of things you can automate.
This is how all the galleries, virtual tours amongst other things work on this site by following a specific directory structure so you can use one line of Smarty code throughout rather than specifically for each page.
http://www.c-h-w.com/large-rooms/lecture-hall/
Re: Product Module - Gallery
Posted: Thu Mar 27, 2014 6:55 pm
by uniqu3
There is also that nice little feature called "module_custom" see:
http://docs.cmsmadesimple.org/customizi ... -templates so one can simply change appearance of a module backend template.
Usually my clients have hard time to remember "alias" of some page or do not want to bother about that so simply want a "clickety click" solution.
A nice thing is that
Gallery Module provides a API to create a dropdown so all we need is a quick UDT which will return a dropdown and small change in
Products editproduct.tpl template file.
The UDT (name it get_gallery_dropdown or whatever you want):
Code: Select all
/**
* @param value | sets a selected value for rendered <select> tag
* @param actionid | actionid of current module
* @param name | name attribute for <select> tag
* @param assign | assign this output to a variable
*/
// Get Gallery module
$Gallery = cms_utils::get_module('Gallery');
// set params
$selected = isset($params['value']) ? $params['value'] : -1;
$actionid = $params['actionid'];
$name = $params['name'];
// create a dropdown using GalleryDropdown() function from Gallery_utils class
$dropdown = Gallery_utils::GalleryDropdown($actionid, $selected, $name);
if (isset($params['assign'])){
$smarty->assign($params['assign'],$dropdown);
}else{
return $dropdown;
}
Create a extra field of type textfield in
Products module.
Now all you need is small change in
Products template, so create a following folder structure (as described in CMSMS Documentation)
"
/module_custom/Products/templates" and copy
editproduct.tpl file from "
/modules/Products/templates".
Somewhere around line 121 there is "custom fields" section, starting like {if $customfieldscount gt 0} where code in foreach loop should be changed as following (supposed your field is named
gallery):
Code: Select all
{if $customfieldscount gt 0}
{$tab_fields}
{foreach from=$customfields item=customfield}
<div class="pageoverflow">
<p class="pagetext">{if isset($customfield->prompt)}{$customfield->prompt}{else}{$customfield->name}{/if}:</p>
<p class="pageinput">
{if $customfield->name == 'gallery'} {* change this to whatever you entered in "Name" input field when creating extra field *}
{if isset($customfield->value)}
{$value = $customfield->value} {* assign saved value to a variable *}
{/if}
{* call the UDT *}
{get_gallery_dropdown actionid=$actionid value=$value|default:'' name="customfield[field-`$customfield->id`]"}
{else}
{if isset($customfield->value)}
{if $customfield->type == 'image' && isset($customfield->image) && isset($customfield->thumbnail)}
<a href="{$customfield->image}" class="fancybox"><img src="{$customfield->thumbnail}" alt="{$customfield->value}"/></a>
{elseif $customfield->type != 'textarea' && $customfield->type != 'dimensions'}
{$mod->Lang('current_value')}: {$customfield->value}<br/>
{/if}
{/if}
{if isset($customfield->delete)}{$mod->Lang('delete')} {$customfield->delete}<br/>{/if}
{if isset($customfield->hidden)}{$customfield->hidden}{/if}
{$customfield->input_box}
{if isset($customfield->attribute)}
<br/>{$customfield->attribute}
{/if}
{/if}
</p>
</div>
{/foreach}
{$endtab}
{/if}
Thats it, now you will have a dropdown listing available galleries in
Gallery module.
Re: Product Module - Gallery
Posted: Thu Mar 27, 2014 8:01 pm
by applejack
Or you can use the Gallery plugin for TinyMCE which then become available as drop down.
Re: Product Module - Gallery
Posted: Fri Mar 28, 2014 10:42 am
by zaidcrowe
i have a man crush on uniqu3 - awesome solution with great focus on the customers ease of use and scalability!