I need to get a starting help on this one.. the documentation did not give me any clues were to start.. I basically want to get a new row in the special data field
On top of that plugin are commented out lines with "register_filter" stuff. Uncomment those and you should see an example of new fields on the backend.
Bert, an example of the custom_data in action you could use is the admin_user address info in the admin->admin section. that's done by custom_data and might give us a direction to go with this. I personally have been stumped by custom_data as well so I'll take a look and see if I can figure anything out as well.
Yeah I saw those, was trying to "change" them by editing the display names etc of each field, but the changes weren't being reflected.
Looking at the functions, what we need to do is use the custom_data_edit_image to add the fields need ("such as price/size/etc") and then save them with the custom_data_save_image function.
That would save the field, but then how would we go about setting the values of those fields on an image?
I know we can use checks by using the getImageCustomData function, as we've already done with the zenpaypal tips from hucste.
Ok, so I'm still a bit confused. You can see in filter_custom_data plugin the custom_data_edit_admin and the array it uses for the fields etc. You don't see anything similar for the custom_data_edit_image, however if you look at admin_edit.php you can see it is actually saving the custom data fields.
It appears that it's using a string with delimiters if I'm looking at this correctly, or am I missing something. For instance look at like 979 in admin_edit.php and the lines below it, is it pulling the data from a string with the different delimiters (such as -city, -location etc)?
edit: Also, if this is the case, would this be the best way? One might think that using an array would be better, but then if we did that we'd basically want to create a customfunction mimicing the custom_data function so that we're not modifying core files, no?
If you want something like "price -> value" you need to use arrays and serialize them. Of course you could create them manuall by demlimiters, too.
I am really not the expert on this, I have never used these filters. Best you wait for sbillard to respond later today. He builts in many nice things I also don't catch up with everytime, if that helps...;-)
Well, there are three aspects of these custom fields we have to deal with:
1. Storage.
There is only one database field, so if we wish to make it look like many we need to store the data in a way that they can be picked apart when we want to use it. PHP has a nice set of functions to take arrays and make them into strings and vice-versa. We use these to store and retireve the data from the database field. Having done that we easily get each of our custom fields as it is an index into the array.
2. Retrieval.
Here we have some choices. The example filter took the simple route and just made the array available globally. Useage of the data is therefore using the appropraite array element. You can, of course, use instead functions/methods to further isolate the implementation from the usage.
3. Admin handling.
Here we have to create the form elements to display and save the data. Each of our pseudo fields gets an `` element in the form. The name of the element needs to be unique, so for images and albums there is a prefix that the admin pages creates for each specific image/album. We prepend that prefix to the unique name of the pseudo field and use this as the `name` of the input element. This HTML is all generated by our "edit" filter.
Our 'save" filter will be called when the form is posted. Its job is to retrieve each the values of these input elements and store them into an array indexed by the pseudo field name. That array is serialized and set into the object's custom data via the `setCustomData()` method.
under the picture is an order buttom (bestel dit item ) choose number of items, color and size in the dropdowns
(these are the customfields with every picture, I now use imagelocation, imageplace etc for these fields which should be changed)
then click ´voeg toe aan winkelwagentje´ (add to the shopping cart) a popup shows the item hads benn placed in the cart, continu shopping or go to the page ´winkelwagen´ in the pagelist on the left, this shows your shopping cart
´Plaats Uw bestelling´ on the shopping cart page means order and this takes you to the order form where you can fill in all your info and when order a mail will be sent to the shop owner as well as to the customer containg an overview of ordered products.
the nopcart part is fully customizible thropugh the nopcart.js and can include taxes, shipping costs etc..
Comments
Looking at the functions, what we need to do is use the custom_data_edit_image to add the fields need ("such as price/size/etc") and then save them with the custom_data_save_image function.
That would save the field, but then how would we go about setting the values of those fields on an image?
I know we can use checks by using the getImageCustomData function, as we've already done with the zenpaypal tips from hucste.
It appears that it's using a string with delimiters if I'm looking at this correctly, or am I missing something. For instance look at like 979 in admin_edit.php and the lines below it, is it pulling the data from a string with the different delimiters (such as -city, -location etc)?
edit:
Also, if this is the case, would this be the best way? One might think that using an array would be better, but then if we did that we'd basically want to create a customfunction mimicing the custom_data function so that we're not modifying core files, no?
I am really not the expert on this, I have never used these filters. Best you wait for sbillard to respond later today. He builts in many nice things I also don't catch up with everytime, if that helps...;-)
1. Storage.
There is only one database field, so if we wish to make it look like many we need to store the data in a way that they can be picked apart when we want to use it. PHP has a nice set of functions to take arrays and make them into strings and vice-versa. We use these to store and retireve the data from the database field. Having done that we easily get each of our custom fields as it is an index into the array.
2. Retrieval.
Here we have some choices. The example filter took the simple route and just made the array available globally. Useage of the data is therefore using the appropraite array element. You can, of course, use instead functions/methods to further isolate the implementation from the usage.
3. Admin handling.
Here we have to create the form elements to display and save the data. Each of our pseudo fields gets an `` element in the form. The name of the element needs to be unique, so for images and albums there is a prefix that the admin pages creates for each specific image/album. We prepend that prefix to the unique name of the pseudo field and use this as the `name` of the input element. This HTML is all generated by our "edit" filter.
Our 'save" filter will be called when the form is posted. Its job is to retrieve each the values of these input elements and store them into an array indexed by the pseudo field name. That array is serialized and set into the object's custom data via the `setCustomData()` method.
you cam see it here:
The owner still has to put the the data with every pic but the first three thumbs on this page already have prices/sizes/colors
http://www.sugarbelly.nl/green/groene+serie+1+detail+hanger.jpg.php
because the site is in dutch here the translation
under the picture is an order buttom (bestel dit item )
choose number of items, color and size in the dropdowns
(these are the customfields with every picture, I now use imagelocation, imageplace etc for these fields which should be changed)
then click ´voeg toe aan winkelwagentje´ (add to the shopping cart)
a popup shows the item hads benn placed in the cart, continu shopping or go to the page
´winkelwagen´ in the pagelist on the left, this shows your shopping cart
´Plaats Uw bestelling´ on the shopping cart page means order and this takes you to the order form where you can fill in all your info and when order a mail will be sent to the shop owner as well as to the customer containg an overview of ordered products.
the nopcart part is fully customizible thropugh the nopcart.js and can include taxes, shipping costs etc..