LemonStand Forum: Image & File Uploads load, but don't show (New Module) - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Image & File Uploads load, but don't show (New Module)

#1 User is offline   Beats 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 192
  • Joined: 18-January 11

Posted 12 January 2012 - 11:11 AM

Hello,

This may be very confusing, but I will try to explain it the best I can :rolleyes:

Basically, I duplicated the Shop/Product Module wanting to lean how it works. And I was able to see how everything flows together...except for one part:

Uploading Images and Files. I can select the file, and I can see the progress bar uploading, but once done - it does not apply to the Product Images. No images shows up.

I narrowed the problem down to this code in the Shop_Product model:

public $has_many = array(
	'images'=>array('class_name'=>'Db_File', 
                    'foreign_key'=>'master_object_id', 
                    'conditions'=>"master_object_class='Shop_Product' and field='images'", 
                    'order'=>'sort_order, id', 'delete'=>true),


Basically, the condition master_object_class='Shop_Product' has to be the same as the model name, in my case master_object_class='Properties_Listing'

When I change the master_object_class to Properties_Listing, the image loads and shows. But when I save the newly created product, the Product does not actually show any images or thumbnails... basically it just saves the images in the backend, and there is no way for me to reference it as a Product Thumbnail or Product Image in the front end.


The replicated module has:
public $has_many = array(
	'images'=>array('class_name'=>'Db_File', 
                    'foreign_key'=>'master_object_id', 
                    'conditions'=>"master_object_class='Properties_Listing' and field='images'", 
                    'order'=>'sort_order, id', 'delete'=>true),


So it got me thinking, for the Property_Listings Module is there a way I can reference the new master_object_class='Properties_Listing' and point it back to master_object_class='Shop_Product'?

Thanks!

Beats
0

#2 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 3,631
  • Joined: 31-October 09

Posted 15 January 2012 - 03:17 PM

Hi Beats,

Your approach is wrong I think. We never need to create related records for one model from another model. If you need to add an extra images field for the Product model, you should extend this model with events - add new relations to the product model, and add corresponding column and form field.

Thank you

Share this topic:


Page 1 of 1

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users

  1. Facebook