Announcement

  •  » Extensions
  •  » Album-specific AddInfo fields?

#1 2013-08-13 15:22:41

Ann
Member
NC, USA
2013-08-10
40

Album-specific AddInfo fields?

Is it possible to set the AddInfo fields to different things on a per-album/category basis?

Here's what I would like to do: I use my images for teaching, so I'd like to have a category for "Botany" containing images of plants and microscope pictures. For a quick overview of each image, I like to add some specific info. On the plant pictures, I would like to add fields for Species, Family, and Native Range, while on the microscope pictures, I would like to add fields for Slide ID, Section, Magnification.

The problem is: with AddInfo I can only figure out how to name the fields once and it will apply for all images in the entire gallery. Is there a way to make it different for different albums? Or can this be achieved with some other trick? Any suggestions welcome, thanks in advance!

Offline

 

#2 2013-08-13 16:25:09

flop25
Piwigo Team
2006-07-06
7037

Re: Album-specific AddInfo fields?

Hello

Take a look at the plugin http://piwigo.org/dev/browser/extension … re.php#L19 -> Here is the html code it adds on the picture page
You can change it like this:

Code:

global $page;
$upcat=explode(',', $page['category']['uppercats']);
if in_array('ID_OF_ONE_PARENT_ALBUM', $upcat)
{
$replacement = ' {if $INFO1}
  <div id="info1 ....
elseif in_array('ID_OF_ANOTHER_PARENT_ALBUM', $upcat)
{
$replacement = ' {if $INFO3}
  <div id="info3 ....

you can even add more field : add here http://piwigo.org/dev/browser/extension … nc.php#L14 http://piwigo.org/dev/browser/extension … re.php#L65 http://piwigo.org/dev/browser/extension … re.php#L72 add change http://piwigo.org/dev/browser/extension … tadmin.php too


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2013-08-13 22:00:43

Ann
Member
NC, USA
2013-08-10
40

Re: Album-specific AddInfo fields?

Hi flop25, thank you for your suggestions! I really like the idea of adding more fields. That way it can be even more flexible with pictures in the same album as only the info fields filled out are showing. I looked at the files and I think I have an idea how this may work, but I have no experience in coding. Should I modify the plugin files, or do I need to use LocalFiles Editor?

Offline

 

#4 2013-08-13 22:03:19

flop25
Piwigo Team
2006-07-06
7037

Re: Album-specific AddInfo fields?

my best advice would be to edit directly the files but change the Plugin URI http://piwigo.org/dev/browser/extension … inc.php#L6 by letting it blank to avoid any update which could overwrite your changes


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2013-08-13 22:08:22

Ann
Member
NC, USA
2013-08-10
40

Re: Album-specific AddInfo fields?

Thank you for your advice! I'll see if I can figure it out when I get home from work tonight.

Offline

 

#6 2013-08-14 05:25:08

Ann
Member
NC, USA
2013-08-10
40

Re: Album-specific AddInfo fields?

Got it, woot! :-) It took me several hours of trial and error, but I finally have another extra info box without getting error messages, yeay! I'm pretty proud of myself for getting it to work despite never having coded anything in php before. I ran into two problems:

1) Just a FYI for anyone else who tries this: I was getting errors because apparently it couldn't add/find the extra field in the database. I had to completely delete AddInfo and verify on the server that the folder and database were gone before installing my modified "MoreInfo" plugin so it would create a new database with the extra column.

2) An unsolved problem/question: For the past two hours, I've been going crazy trying to figure out why the info wasn't showing on my pictures. It looked all fine on the admin site and I didn't get any errors, but nothing was showing up with the pictures.

After quite a bit of fiddling around, I figured out that the "Author" field needs to be checked under Photo Properties or the AddInfo fields won't show on the photo page. I can uncheck all the others, but if I uncheck the Author then the info disappears with it. I was hoping to be able to uncheck the Author info since I'm adding a copyright notice anyway, so it just repeats information.

I found an old thread talking about a similar issue, but in that case it was the Posted On date that the info fields depended on, and the suggestion was to replace line 14 and 35 datepost by datecreate in initpicture.php. I thought, great, that should for me as well!

The problem is: I can't find either datepost, datecreate, or author in the initpicture.php file! I did find one instance of datecreate in the maintain.inc.php file:

Code:

$query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("AddInfo","datecreate","AddInfo");';

So I'm at a loss as to how to change the dependency of the AddInfo fields on the Author info. Any suggestions? Thanks!

Offline

 

#7 2013-08-14 09:55:48

flop25
Piwigo Team
2006-07-06
7037

Re: Album-specific AddInfo fields?

Congrats!!

About your problem: http://piwigo.org/dev/browser/extension … re.php#L17 means that the plugin is searching for the div with id $conf['AddInfo'] which is datecreate by default, and replace it with <div id="info1"...</div><div id="'.$conf['AddInfo'].'" class="imageInfo"> so it prepends its custom html to that div

http://piwigo.org/dev/browser/extension … in.php#L48 => it seems like you have an admin page for that plugin to choose where the html goes


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#8 2013-08-14 14:20:25

Ann
Member
NC, USA
2013-08-10
40

Re: Album-specific AddInfo fields?

Thanks again for your help!

I got it figured out now: When choosing where to place the AddInfo fields in the plugin configuration screen, you have to add them before a field that contains entries (neither unchecked in photo properties nor left blank on the edit photo page) or it won't show.

For example, I had chosen to place the additional info before the Author field, so when I unchecked Author in photo properties, it wouldn't show. I had tried to place it before the create date info, but it wouldn't show either. I didn't realize though that I had not entered a create date on the image I was using for testing. Once I entered a date, it worked. I can also place it in front of tags and uncheck anything else so that only the additional info and the tags are showing. So it's working perfectly now! Just took a while to figure out. :-)

Offline

 

#9 2013-08-14 14:56:40

flop25
Piwigo Team
2006-07-06
7037

Re: Album-specific AddInfo fields?

you can also add those fields wherever you want by changing the $search string or manually by adding the html code in a Template extension of picture.tpl


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#10 2013-08-15 03:36:54

Ann
Member
NC, USA
2013-08-10
40

Re: Album-specific AddInfo fields?

Hi flop25, again - thanks so much for your insightful suggestions!

Offline

 
  •  » Extensions
  •  » Album-specific AddInfo fields?

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact