Pages (2): 1 2   
Member
Member
BigLouis87   08-08-2012, 14:47
#1

I need to write a user page that shows all the images that a user owns, a sort of search by tags (clicking on the word) but by owner. I need it to collect every image a user uploads on my site.
The search form doesn't have a 'owner' option and I can't find a specific function in the documentation.
What function can I use to print them? Any suggestion?
Thanks

Administrator
Administrator
acrylian   08-08-2012, 15:16
#2

Probably there should be a search field for the owner as there is one for the author of Zenpage items.

You have two ways to get them instead:
a) Use the object model (recommended)
b) Use a MySQL query
c) Use the object model to assign a tag to each image based on the owner name and then search that one (we use a tag "author_" for credits for example we do that manually as 3rd party authors are no "users" on our site)

Member
Member
BigLouis87   08-08-2012, 17:52
#3

I cannot use the tag "author_bob" because I'm already using tags to classify images, that tag would appear among the other "true" tags.

uhm... I already use the object model to assign the owner to the image while uploading (using $image->setOwner('bob');), my idea was to recall that by $_zp_current_image->getOwner();, modifying somehow search.php... could be that a good idea?
I haven't clearly understood how a search is done yet, but I think I could clone the model of search by tag and substitute the control on tag with the control on the owner...

Administrator
Administrator
acrylian   08-08-2012, 18:03
#4

If you want to hide a tag, you can of course use custom tag display functions to filter that. (we have alway a get variant to each print one and of course the object model).

Modifying the search is surely an option but not recommended because of upgrade. The best would be to open a ticket so it is actually added. Probably it was just forgotten or something. My colleague will be able to answer this I guess.

Member
Member
BigLouis87   08-08-2012, 22:49
#5

Thank you for the replies, I partially solved with a $_GET['owner']: in my case all user images are in the same album; so when I call the album, if I use ?owner=bob then this variable is passed in the function
$personality->theme_content($map, $_GET['owner']);
and then used to skip image prints that don't have the requested owner
if ($_zp_current_image->getOwner() == $owner || $owner == '') { print the thumbnail }

This worked for me, but if you said Stephan could have a cleaner and more general way to get it, I'll wait. However, it will be a nice feature having it among the search fields, in a future release.

Member
Member
sbillard   08-08-2012, 23:41
#6

The simplest way to implent this is to add
$this->search_structure['owner'] = gettext('Owner');
To the constructor of the search class. Then the field shows up in the option list and can be checked to cause it to be included in on the search form.

I am sure that it is just an oversite that it is not already included. I will make sure it is part of 1.4.4

Member
Member
BigLouis87   09-08-2012, 11:31
#7

Thank you, now it seems to work! It was so simply...

Member
Member
BigLouis87   09-08-2012, 13:25
#8

uhm, I think there is a bug, or something.
I simply added $this->search_structure['owner'] = gettext('Owner'); to the class-search _constructor, but when I search by owner it shows me only 11 results, while that user (the admin) has uploaded about 50 images.
I checked the images not shown in search results, they belongs to that user too.

Administrator
Administrator
acrylian   09-08-2012, 14:28
#9

Be sure the images are published and look at your search cache settings. by default results are cached 30min to lower overhead.

Member
Member
sbillard   09-08-2012, 17:44
#10

Look in your database. That field may not be set for all the images. When the admin looks at this it uses the object model, so if an image is in an "owned" album it will be marked as owned by the album owner.

(This is, of course, the problem with just looking at database fields. But I do not know how the serach could do otherwise.)

Member
Member
BigLouis87   09-08-2012, 19:06
#11

You're right, Stephan. All the images uploaded within the zip has NULL owner (and lot of other fields) in db, even if in the admin panel was assigned to their album's owner.
It needs to "save" every pages (even without changing anything) in the album/image control panel in order to set the right parameters for every image.

Member
Member
sbillard   09-08-2012, 21:39
#12

Ok. We can make the album owner propegate to the image by adding code to the image updateMetaData() method.

after the lines that read:
$alb = $this->album; if (!is_null($alb)) {
add:
if (!$this->get('owner')) { $this->setOwner($alb->getOwner()); }
Of course, this requires a metadata refresh if the album owner is changed after the image is discovered.

This will be added to the 1.4.4 release

Member
Member
BigLouis87   10-08-2012, 08:45
#13

great, it works. Thank you!

Member
Member
sbillard   10-08-2012, 15:52
#14

I should point out the downside of this change. Once the image owner field is set it becomes "disconnected" from the album owner. So changing the album owner does not change the image owner. All further changes have to be made on the image itself.

Member
Member
BigLouis87   10-08-2012, 18:59
#15

I think album/images structure should be similar to the unix structure of folder/files; the album should have its own owner, so as any image should. In this vision it's natural that album owner is indipendent from any singular image owner. At least zenphoto uses a unix filesystem to manage images, doesn't it?
However it could be nice having an option to change every image owner while changing album owner.
My 2 cents

Member
Member
geemike   25-01-2013, 19:44
#16

A bit late to the party here, but I have modified my image.php to include the "owner" label:

`

`

but really I would like this to be a link and a tag allowing clicking on the owner to do a tag search. I see above that you are recommending using the object model to "assign a tag to each image based on the owner name". Can you provide some tips on how to do this?

Thanks

Member
Member
sbillard   25-01-2013, 20:30
#17

Custom serches can be done on "owner", so a tag may not be needed.

The link for "owner" should look something like:

domain.com/page/search//?searchfields=owner

where `` is the owner of the object

Member
Member
geemike   25-01-2013, 22:11
#18

Great. URL based search is perfect for my needs. Unfortunately the syntax must be off slightly. On my site you can see the owner is "paul" but http://skishots.calgaryalpine.com/page/search/paul/?searchfields=owner yields 0 results.

Administrator
Administrator
acrylian   25-01-2013, 23:17
#19

Did you enable the field owner for search?

Member
Member
sbillard   26-01-2013, 01:44
#20

Also the owner must be set. You may have an "owner" shown because the album is owned without having the image "owner" field populated.

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.