PDA

View Full Version : Custom fields in EE admin


Ewan
1st of June 2005 (Wed), 02:15
A suggestion for future versions...

How feasable would it be to add the facility to create custom text fields through the EE admin utility?

As an example, I have manually added 2 fields to the ee_photo database table to record a plant or animal's latin name and a location's map reference. I have then added the necessary code to the photo display page to show these fields under the picture title, where appropriate.

eg:

http://www.oaktreephoto.co.uk/gallery/photo.php?photo=323

and

http://www.oaktreephoto.co.uk/gallery/photo.php?photo=65

As I have done it manually it will be fun when I upgrade EE and have to remember what changes I made!

I guess if there could be a number of text areas at different places on the photo page that users could use for different purposes and could be switched on/off as necessary, that would be a way forward.

Would people find that useful?

HMetal
1st of June 2005 (Wed), 11:38
A suggestion for future versions...

How feasable would it be to add the facility to create custom text fields through the EE admin utility?

As an example, I have manually added 2 fields to the ee_photo database table to record a plant or animal's latin name and a location's map reference. I have then added the necessary code to the photo display page to show these fields under the picture title, where appropriate.

[...]
As I have done it manually it will be fun when I upgrade EE and have to remember what changes I made!
[...]
Would people find that useful?

I would find it useful but, while we can't expect Pekka to add everything we desire (aww! http://www.photography-on-the.net/forum/images/smilies/icon_sad.gif), I can give you a tip to make patching your install easier.

When I install any PHP application, I always keep a pristine copy of the original. If I make changes to the code and a new release comes out, I just "diff" the original copy and my modified version. This gives me a list of the lines I changed, which I can then refer to, in order to re-add my changes.

You can also "diff" the new release and your modified install, and then only add the changes that you know YOU have made.

There are a lot of ways to accomplish this but the best I've found, at leat under Windows, is a utility called BEYOND COMPARE. It can diff single files or complete directories.

You can find it here: http://www.scootersoftware.com/

MikeCaine
2nd of June 2005 (Thu), 02:24
I find commenting out the code I'm changing and then adding my own amendments with liberal comments also helps when it comes to upgrades. That way I can see what the original code was, how I've changed it and also why

Ewan
2nd of June 2005 (Thu), 05:03
Thanks guys. I do comment my code (haphazardly) but don't always keep a record elsewhere of what changes I've made or what files I've edited. A lesson to be learned I guess.

Thanks for the link to the diff software.

reiger
5th of October 2005 (Wed), 04:39
Ewan,
Any chance you could give more details on how you made your changes? I would like a similar change. I would like to replace the Location line below the Title with the IPTC Provider field for my genealogy pages. The Provider/Credit metadata is in the photos; now I just need to get that info into EE.
Thanks to anyone who can help!

Ewan
5th of October 2005 (Wed), 09:38
Here's what I did. At least I think this is everything; as I said, my commenting was a little sparse! Line numbers will probably be a little out compared to your own.

I added 2 fields to the ee_photo table in the database: ee_latin_name and ee_gridref.

The data in these is accessed by the photo.php page in the gallery root:

There's a query starting at line 569 in my version of the file that starts


$basics_sql = "SELECT
ee_photo.ee_photo_id,
ee_photo.ee_counter_id,
..
..
..
ee_photo_showcountry,
ee_photo_panorama

FROM


This query now inlcudes the 2 new tables:


$basics_sql = "SELECT
ee_photo.ee_photo_id,
ee_photo.ee_counter_id,
..
..
..
ee_photo_showcountry,
ee_photo_panorama,
ee_latin_name,
ee_gridref
FROM


Starting at line 1005 is the comment: // SQL DATA TO VARIABLES

I added the following 2 lines to that section:


$latin = ee_stripslashes($xyz["ee_latin_name"]);
$gridref = ee_stripslashes($xyz["ee_gridref"]);


Starting at line 1575 is the following function which I've modified (in my own clumsy coding) to display the data in the fields where appropriate (basic logic is 'IF FIELD IS NOT EMPTY THEN DISPLAY DATA FROM FIELD):


ob_start();
print "<span class=\"subheader\">";
if ($latin != "") //
{ //
print "<i>"; // Ewan's
print $latin; // mods
print "</i><br>"; //
}; //
if ($photo_showcountry =="1") {
// PRINT LOCATION

if ($city == "Unknown" OR $country_id == "191")
{
//$comma = " ";
}
else {
//$comma = ", ";
}
if ($city != "Unknown") print $city;
if ($gridref != "") //
{ //
print "<br>"; //
print "<font size=\"1\">"; // Ewan's
print "OS grid ref: "; // mods
print $gridref; //
print "</font>"; //
}; //
//if ($city != "Unknown" AND $country_id != "191") print $comma;
//if ($country_id != "191") print $country;

print "</span>";
}
$location_html = ob_get_contents();
ob_end_clean();


Here's an example of the output:

http://www.oaktreephoto.co.uk/gallery/photo.php?photo=508

I hope this helps :)

reiger
5th of October 2005 (Wed), 18:36
Thanks, Ewan. I have no db or php skills yet, and while I usually love nothing more than tinkering on the computer and learning new skills, I have a newborn in the house ensuring I get next to no time on hobbies. That's not a complaint, mind you. So I really appreciate your giving me the jump on this modification.

So how are you populating the two new fields in the database? Did you have to modify other EE php files for photo loading and database population? Does EE pull the information out of each photo's metadata and then populate the new fields of the db, or our you filling in the data into the db yourself?

Nice photos BTW. I really like the color in the coot photo.

Ewan
6th of October 2005 (Thu), 04:33
So how are you populating the two new fields in the database? Did you have to modify other EE php files for photo loading and database population?
I intended to create a web-page form to input the data but it's well down my to-do list (and I'd have to refresh my SQL/php skills significantly ;) ). All the data is entered manually through the database admin interface that my web host provides. Sorry - I should have mentioned that. I don't add new pictures all that often so the system works fine for now.

Does EE pull the information out of each photo's metadata and then populate the new fields of the db
That's a bit too clever for me!

Nice photos BTW. I really like the color in the coot photo.
Thanks - appreciated.

reiger
7th of October 2005 (Fri), 23:01
Wow. That was painless. I got the new column added to the table, made some sample entries, and updated the php file after backing up the original. Thanks again!