Page 1 of 1

Product Manager: image display in product editor

Posted: Fri Apr 10, 2009 6:03 am
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...

Re: Product Manager: image display in product editor

Posted: Fri Apr 10, 2009 5:20 pm
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.

Re: Product Manager: image display in product editor

Posted: Sat Apr 11, 2009 12:34 am
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...

Re: Product Manager: image display in product editor

Posted: Sun Apr 12, 2009 4:34 am
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;

Re: Product Manager: image display in product editor

Posted: Sun Apr 12, 2009 1:33 pm
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.