Product Manager: image display in product editor

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
sysmaster
Forum Members
Forum Members
Posts: 23
Joined: Sun Aug 26, 2007 2:08 am

Product Manager: image display in product editor

Post by sysmaster »

I noticed that the request for displaying images (thumbnails) in the product editor came up several times,
also I wanted to have it there, so it would be easier to see what is linked to it.

So, I did a bit of "hacking", I'm sure that I did not do it the proper way and used the right techniques,
but with my limited knowledge how certain thing come together in CMCMS, this is my temporary solution:

Anybody who can improve it feel free to post amendments

Also, this is designed for the default image that is in the product structure, if there are additional images, this is not
working, because then only the last image that is detected in the "customfields" loop will be put in the variable.

in the "editproduct.tpl": add the red code....

{foreach from=$customfields item=customfield}


{if isset($customfield->prompt)}{$customfield->prompt}{else}{$customfield->name}{/if}:
{if $customfield->prompt =='image'}{/if}



                                  {if isset($customfield->value)}{$mod->Lang('current_value')}: {$customfield->value}
                                    {if isset($customfield->delete)}{$mod->Lang('delete')} {$customfield->delete}{/if}
                                  {/if}
                                  {if isset($customfield->hidden)}{$customfield->hidden}{/if}{$customfield->input_box}
                                  {if isset($customfield->attribute)}{$customfield->attribute}{/if}
                               

{/foreach}


and in "action.editproduct.php": add the red code.... case'image' is to be found around line 419

  case 'image':
            if( $this->GetPreference('autowatermark') == 'adjustable' )
              {
                $field->attribute = $this->Lang('watermark_location').' '.
                    $this->CreateInputDropdown($id,'customfield_attr[field-'.$fielddef->id.']',$wmopts,-1,'default');
              }
    $field->delete = $this->CreateInputCheckbox($id,'customfield[deletefield-'.$fielddef->id.']',
1,0);
    $field->input_box = $this->CreateFileUploadInput($id,'customfield[field-'.$fielddef->id.']','',50);
    $field->hidden = $this->CreateInputHidden($id,'customfield[field-'.$fielddef->id.']',$value);
    $destdir = cms_join_path($gCms->config['uploads_url'],$this->GetName(),'product_'.$compid);
    $desttn = cms_join_path($destdir,'thumb_'.$value);
    $this->smarty->assign('bild',$desttn);

    break;

sm...
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Product Manager: image display in product editor

Post by tyman00 »

Thanks for contributing. Please keep in mind that any future upgrades to Products could cause these changes to be lost.

While I can see the benefit of displaying the thumbnails, I can also see the other side of the fence. If a user has 15-20 image fields the extra height from the thumbnails would cause the Product creation/editing page to become very long and tall.
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.
sysmaster
Forum Members
Forum Members
Posts: 23
Joined: Sun Aug 26, 2007 2:08 am

Re: Product Manager: image display in product editor

Post by sysmaster »

tyman00 wrote: Thanks for contributing. Please keep in mind that any future upgrades to Products could cause these changes to be lost.

While I can see the benefit of displaying the thumbnails, I can also see the other side of the fence. If a user has 15-20 image fields the extra height from the thumbnails would cause the Product creation/editing page to become very long and tall.
I'm aware of the drawbacks of the "patch", but for the current requirement it will do, since I only have one picture to associate with a specific product.
Should the module be upgraded and there is no alternative approach in the new version, I'll have to add my little patch again, that's life.

If the user has more than one picture, this routine will not help much, he will see X copies of the last "image of images" that he has.

It is just a temporary solution since I expect (hope) that future releases of the Products module will have a embedded solution for it.


SM...
sysmaster
Forum Members
Forum Members
Posts: 23
Joined: Sun Aug 26, 2007 2:08 am

Re: Product Manager: image display in product editor

Post by sysmaster »

In follow up to the original patch...
Since the original would only show the last picture, following "corrections":
These minor changes will show all pictures that are related (stored) for the product.

A further option could be that the script is modified to have a [Show] button instead of the image and that
on-click a pop-up shows the related image (this to prevent long pages when there are many pictures), or something like that...

As already mentioned by tyman00, making those changes could be temporary, when Product manager get's upgraded, you might have to re-apply the patch.

If one has already implemented this patch, he should follow the modifications to the first approach, otherwise implement below, omitting the "strike through" lines.

in the "editproduct.tpl": modify the red code....

{foreach from=$customfields item=customfield}
     
         
            {if isset($customfield->prompt)}{$customfield->prompt}{else}{$customfield->name}{/if}:
            {if $customfield->prompt =='image'}{/if}
            {if isset($customfield->image)}image}">{/if}
   
           
                                                   
                                  {if isset($customfield->value)}{$mod->Lang('current_value')}: {$customfield->value}
                                    {if isset($customfield->delete)}{$mod->Lang('delete')} {$customfield->delete}{/if}
                                  {/if}
                                  {if isset($customfield->hidden)}{$customfield->hidden}{/if}{$customfield->input_box}
                                  {if isset($customfield->attribute)}{$customfield->attribute}{/if}
                               
         
      {/foreach}





and in "action.editproduct.php": modify the red code.... case'image' is to be found around line 419


  case 'image':
            if( $this->GetPreference('autowatermark') == 'adjustable' )
              {
                $field->attribute = $this->Lang('watermark_location').' '.
                    $this->CreateInputDropdown($id,'customfield_attr[field-'.$fielddef->id.']',$wmopts,-1,'default');
              }
    $field->delete = $this->CreateInputCheckbox($id,'customfield[deletefield-'.$fielddef->id.']',
1,0);
    $field->input_box = $this->CreateFileUploadInput($id,'customfield[field-'.$fielddef->id.']','',50);
    $field->hidden = $this->CreateInputHidden($id,'customfield[field-'.$fielddef->id.']',$value);
    $destdir = cms_join_path($gCms->config['uploads_url'],$this->GetName(),'product_'.$compid);
    $desttn = cms_join_path($destdir,'thumb_'.$value);
    $this->smarty->assign('bild',$desttn);
    $field->image= $desttn;
   // above for testing
    break;
Last edited by sysmaster on Sun Apr 12, 2009 11:00 am, edited 1 time in total.
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Product Manager: image display in product editor

Post by tyman00 »

You can submit this patch to the Feature Request section of the Product manager in the developers forge. The module author may consider implementing it in their next release.
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”