I have built a photo gallery that uses folders, with images within those folders. Paint Layouts paint the asset listings for these folders to make it into a gallery. (http://www.nnhubbard.com) What I am wanting to do, it allow comments for images. I know how to set this all up, but the problem lies in where I could create the comments that are associated with each image, as it is not possible to create comment assets a children of image assets.
So, does anyone have some tips on how I could associate comments with each image, even if those comments are not children of the image? I am slightly more limited with this, as I only have the GPL version for these sites.
And yes, I created another account. I need to keep my work posts separate from my personal website/business posts. 
I've been thinking about this all weekend and I still don't have a solution for you. :( In the meantime, I would log a feature request so that the comment asset can be created as a child of an image asset.
bug #3052
Thanks Avi. I will keep on trying to think of a solution to this. My last idea was to create comments in the parent folder, then use an asset listing to group the comments by metadata field, which I would have the image asset id entered. So, at least it would group them by image asset id, and then I could use javascript to show only the group for each image, on the "Full Image Size" page. Not the ideal solution, but it would probably work.
I am surprised that no one has ran into this before, but, maybe they have, and just never mentioned it. :)
Yeah, it is curious. I was also toying with a folder for each image with the image set as the thumbnail, but that would introduce all sorts of issues when uploading new images.
Yeah, I am working to keep the gallery really clean and simple, so that I just create a new folder, which will be the new gallery, and then quick upload the photos and then I am done. Thumbnails are created by a trigger, and paint layouts list all of the thumbs and manage the full size.
Edit: Arg, this two accounts thing is going to mess me up! :)
If anyone is interested, I came up with a working solution for this. It is not as nice and pretty as having comments created under each image, but it works.
First, each comment asset has an imageID metadata field. Using the asset builder for the comment, the images ID is appended to the form, and submitted, so that the comment has an association with the image that the comment is about. Then, using an asset listing, with grouping by metadata, I set it up so that it would group based on the imageID. So, for each image, there will be a set of comments associated with this. These comments are created in the images parent folder. Then, using jQuery, all image groups are hidden, and only the current imagesID group is shown.
$(document).ready(function(){
//Add input field into comments asset builder
$("p#hiddenMeta").append("");
//Hide all comment groups
$('.commentGroup').hide();
//Show only current image id's group
$('#a%asset_assetid&').show();
});This solves my problem for now, until a Matrix solution is added. I could go into more detail if anyone would like...
If you are willing to change the code a bit (for testing) to see if adding comments under an image will work for you, make the following change to /path/to/matrix/core/assets/files/file/file.inc
Look for the function _getAllowedLinks (around line 477). It should look like this:
public function _getAllowedLinks()
{
return Array(
SQ_LINK_TYPE_1 => Array(),
SQ_LINK_TYPE_2 => Array(),
SQ_LINK_TYPE_3 => Array(),
SQ_LINK_NOTICE => Array('image' => Array('card' => 1, 'exclusive' => FALSE)),
);
}//end _getAllowedLinks()</pre><br />
This method tells Matrix what types of children an asset can have. Files (and images) are not allowed any children because it doesn't make sense to have a URL like images/fred.jpg/home, although Matrix should support that fine.
Change the method so it looks like this:
public function _getAllowedLinks()
{
return Array(
SQ_LINK_TYPE_1 => Array('comment' => Array('card' => 'M', 'exclusive' => FALSE)),
SQ_LINK_TYPE_2 => Array('comment' => Array('card' => 'M', 'exclusive' => FALSE)),
SQ_LINK_TYPE_3 => Array(),
SQ_LINK_NOTICE => Array('image' => Array('card' => 1, 'exclusive' => FALSE)),
);
}//end _getAllowedLinks()</pre><br />
Now you can have comments TYPE1 and TYPE2 linked under an image. IIRC, you don't need to run any install scripts after doing this, but if it doesn't work, run step_03.php.
Greg, I am more than happy to change my code to try to get this working.
I made the change, but get the following error when trying to create the comment, and hitting submit:
Fatal error: Call to undefined method Comment_Edit_Fns::processFileUpload() in /home/websites/mysource_matrix/core/assets/files/file/file.inc on line 236
It seems like it partially worked, as I don't think it would even let me get to the asset creation screen before, when trying to create a comment under an image.
Let me know if I can try anything else
That is part of the clone method, but I'm not sure why it would be trying to clone an existing asset during creation. Are you able to see a backtrace for the error?
I can't get a backtrace on it, I don't get the backtrace link at all, or the normal matrix colored warning, it was a white screen.
Logs show it as a Raw Entry.
Bummer. Modify /home/websites/mysource_matrix/core/assets/files/file/file.inc and at the top of that clone function, add this code:
trigger_error('Testing', E_USER_ERROR);That should kill the script just before it would normally die, but use a Matrix error message with a backtrace. That should at least allow me to figure out where it is getting called from.
We might want to switch this off to email to stop polluting this thread ![]()
You can contact me at gsherwood at squiz dot net
If there was this sort of feature in Matrix, this would be considered a bug, but given nothing can be significantly linked to a file asset in the released code, there's no way it can show up (from a quick perusal of the code).
When an asset is created underneath another, a cloneComponents() function is called to clone such things as metadata, workflow, permissions etc, so it "inherits" those of the parent ("inherit" in quote marks because it's not true inheriting, more "cascading" in a Matrix sense, but never mind). In particular, as of version 3.18.x, it clones metadata and workflow schemas, permissions, content tags and roles. It does not clone attributes, metadata contents or data (ie. data directory contents).
In the case of File asset, it doesn't check to see what components are being cloned - in the current code, it assumes that all components is being cloned (which is the case when a whole asset is being cloned - this would be the only case that this would get called, I think) - and therefore tries to clone its file data. Obviously, when it tries to pass it to a comment asset, it fails.
I get the feeling that if the cloning of file data is limited so that it only happens when a certain component is cloned (I need to work out what it is; I think it's "data" from the looks of it) or "all" components are cloned, then the addition of comment assets would possibly work.
[quote]If there was this sort of feature in Matrix, this would be considered a bug, but given nothing can be significantly linked to a file asset in the released code, there's no way it can show up (from a quick perusal of the code).
When an asset is created underneath another, a cloneComponents() function is called to clone such things as metadata, workflow, permissions etc, so it "inherits" those of the parent ("inherit" in quote marks because it's not true inheriting, more "cascading" in a Matrix sense, but never mind). In particular, as of version 3.18.x, it clones metadata and workflow schemas, permissions, content tags and roles. It does not clone attributes, metadata contents or data (ie. data directory contents).
In the case of File asset, it doesn't check to see what components are being cloned - in the current code, it assumes that all components is being cloned (which is the case when a whole asset is being cloned - this would be the only case that this would get called, I think) - and therefore tries to clone its file data. Obviously, when it tries to pass it to a comment asset, it fails.
I get the feeling that if the cloning of file data is limited so that it only happens when a certain component is cloned (I need to work out what it is; I think it's "data" from the looks of it) or "all" components are cloned, then the addition of comment assets would possibly work.[/quote]
Thanks Luke. I am continuing this with Greg, through email, but I am sure he will see your post.
Hi everyone,
I'm trying to do this currently, did anything become of it?
Cheers,
[quote]Hi everyone,
I'm trying to do this currently, did anything become of it?
Cheers,[/quote]
Nothing became of changing the Matrix code. Greg helped me through that, and in the end, it was not a workable option.
I came up with a jQuery solution that worked nicely for my needs. Let me know if you are interested in hearing about this.
[quote]Nothing became of changing the Matrix code. Greg helped me through that, and in the end, it was not a workable option.
I came up with a jQuery solution that worked nicely for my needs. Let me know if you are interested in hearing about this.[/quote]
We do have a version (or two) of a file asset that allows children, and paint layouts, as very experimental internal UK code. You
can add a paint layout that displays wither the raw content of the file (you need a custom design area that can set the right headers too),
and have another that just displays metadata. It also removes the child restrictions.
I am not sure I can see any way in which it can be merged into the core though, so its right at the bottom of the priority list. If there
is sufficient interest I will talk to Greg about it. It is for a project that wants a video asset that can be commented on, so you dont need
to create two assets for each video you upload.
[quote]We do have a version (or two) of a file asset that allows children, and paint layouts, as very experimental internal UK code. You
can add a paint layout that displays wither the raw content of the file (you need a custom design area that can set the right headers too),
and have another that just displays metadata. It also removes the child restrictions.[/quote]
Greg and I got this far testing this in Matrix. He had me edit the code so that the image asset would allow children. In the end, it DID work, but only if "Allow Unrestricted Access" was set to no. If it was set to yes, Apache was serving the file, and the child comment could not be found. E.g. /__data/assets/image/0013/2290/test.jpg/comment was not a valid URL.
How are you getting around this problem?
I am not really looking for a solution for this still, my workaround is quite etiquette for my needs. 
I am also having this problem and Nic’s solution blows my mind
I think I’ll wait for the Matrix guys to provide an easier answer.
A related issue to Web 2.0 image galleries in the Matrix… Social Bookmarking. Of course you have to paint the images with an asset listing to be able to toggle through the photos one at a time, however this causes your social bookmark links (example: http://del.icio.us/post?url=%asset_url%) to bookmark the url for the gallery within the folder you are navigating instead of a specific image within the gallery.
On a side note, I have been successfully using paint layouts to add social bookmarking and comments to my videos by using Standard Pages to reference .flv files on our video server. http://del.icio.us/post?url=%asset_url%) However, I cannot toggle through the videos individually because I am not using an asset listing for these.
Really? I didn't think it was that hard, it was just hard to come up with the concept. Did you look at my blog? http://building-puc.blogspot.com/2008/05/two-new-matrix-sites.html If you need me to explain it more I would be happy to.
[quote]A related issue to Web 2.0 image galleries in the Matrix... Social Bookmarking. Of course you have to paint the images with an asset listing to be able to toggle through the photos one at a time, however this causes your social bookmark links (example: http://building-puc.blogspot.com/2008/05/two-new-matrix-sites.html to bookmark the url for the gallery within the folder you are navigating instead of a specific image within the gallery.[/quote]
Do you have an example of this?
[quote]Greg and I got this far testing this in Matrix. He had me edit the code so that the image asset would allow children. In the end, it DID work, but only if "Allow Unrestricted Access" was set to no. If it was set to yes, Apache was serving the file, and the child comment could not be found. E.g. /__data/assets/image/0013/2290/test.jpg/comment was not a valid URL.
How are you getting around this problem?
I am not really looking for a solution for this still, my workaround is quite etiquette for my needs. :)[/quote]
Yes, we made this option never apply to the new asset type. It doesnt really make sense, especially once you have a paint layout on it…