Add More Custom Fields via Config - Page 2 Add More Custom Fields via Config - Page 2
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Add More Custom Fields via Config

Started by pslawinski, November 13, 2005, 12:16:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pslawinski

Yes, you will have to reinstall the mod if you upgrade to another version of CPG

Joachim Müller

Yes. After upgrading, you will have to re-apply every mod.

Dr Preacox

Its just a shame that you cant make every mod into a plugin, maybe for the future, but im content at the moment.
My Mods:
Making Memberlist Public - VIEW
Different Way of Displaying Categories - VIEW
Coming Soon - Automated Sub Domains -MOD

flar

GauGau, what would it take to get this considered for integration into the main source?  I'd be willing to do some work to clean it up to make it worthwhile to integrate.

flar

In my last updates to this mod I created a "number of user fields" form entry on the config page to change the num_user_fields.  This does the job, but I'm wondering if that is the best UI for this.  The main issue I see with it is that you have to change the number, then commit the changes, then reload the config page to be able to type in the field names.  It's relatively straightforward, but a little indirect.

An alternative that I considered was to always show "N+1" textfield form items on that page with the extra "N+1th" field being blank, obviously.  If it gets filled in, then the number of user fields is automatically increased to match and the next time the page is loaded there will now be a new N+2th blank textfield.  I didn't really like that idea as it seemed a little indirect and it raises bizarre issues like "what if they fill in the N+1 textfield, but empty out the N-1 textfield - should we try to compact which fields are named or reuse the now unused N-1th field?"  Also, to add several fields you have to add them one at a time and commit each new field separately.

Another alternative would be to add a form button to the bottom of that tab that says "Add another user field".  Ideally some javascript could add the new field dynamically and immediately without having to reload the page, but I'm not the world's greatest javascript expert.  If it did have to reload the page then that raises the question of whether or not to commit any current changes, and if not then ideally we should reload it with all of the current edits intact without commiting them which I'm guessing isn't trivial.

I suppose that some javascript could also be written to automatically add the new textfield entries when the user changes the "number of user fields" item in the current solution as well.  Some javascript could/should probably also be added to verify that the field contains a number and it is >= 4.

Any other ideas or thoughts on these alternatives?

Dr Preacox

or the other option is having the custom feilds manager seperate, like the plugins, then you'd have something like this

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.dc-6.com%2Fdrpreacox%2Fidea.jpg&hash=67562ea0da21427dd69ec6ca7764019c27a2199e)

I think this would be a good option. what say you?

postscript: if the image is taking bandwith (its on my server) then I'll make it a link.
My Mods:
Making Memberlist Public - VIEW
Different Way of Displaying Categories - VIEW
Coming Soon - Automated Sub Domains -MOD

Tranz

Quote from: Dr Preacox on May 29, 2006, 05:11:11 PM
postscript: if the image is taking bandwith (its on my server) then I'll make it a link.
You can attach the image in advanced post options.

dbh123

Hi,

I also had the problem that the custom fields were set back to empty when I set the custom fields. The problem turned out to be that the line

$userFields[]=$_POST['user$i'];

in editOnePic.php (around line 45) should have been:

$userFields[]=$_POST["user$i"];

The single quotes were preventing variable substitution.

Thanks for the great modification. Should definitely be a part of the release version.

Darren.



Quote from: fredt on April 19, 2006, 09:09:14 AM
Where did this get to?
I love the mod - it became the tipping point for selecting Coppermine.

I added 16 fields - all came up in the config files.  Uploaded some images using Batch upload. The first image accepted my data in each fieled - and every image after that repeated the same data as contained in the first image.   Checked the datatbase - all 20 user fields are there.

Then went to edit the data for each image - nothing changed.  Checked with debug running.  Debug does not report anything - in fact it appears that nothing happened at all.
Any thoughts?
Fred

pslawinski

Thanks for pointing out that error dbh123.

I used code which was slightly different than what you see here for my own gallery.

I have fixed the errors you mentioned in the code posted at the beginning of this topic.

lemonlime

I got it working after a bit of trial and error. Thank you.

Only issue is that is that the additional fields don't work in the search: they are listed but always return a result of no matches.


pcinfoman

Well, it seems that several people are having a problem with the database error of:
----------------------
While executing query "UPDATE cpg14x_pictures SET aid = '107', title = 'Frog', caption = '', keywords = '', user1 = 'Jul 1996', user2 = 'Fiberglass', user3 = 'H2', user4 = '1840', user5 = '' WHERE pid='348' LIMIT 1" on 0

mySQL error: Unknown column 'user5' in 'field list'
----------------------
However, I do not see any solutions.

What is the mysql command in order to add this to the database?

Nibbler

ALTER TABLE cpg14x_pictures ADD user5 VARCHAR(255)

or use a GUI like phpmyadmin.

pcinfoman

Quote from: Nibbler on January 10, 2008, 07:10:33 PM
ALTER TABLE cpg14x_pictures ADD user5 VARCHAR(255)

or use a GUI like phpmyadmin.

Thank you. Works like a charm. Too bad I have to do this everytime I add a new custom field, but nevermind. I appreciate the work you all did and thank you for solving my problem..

bgrega

I'm no coder by any means and I'm trying to edit my files and use this awesome mod.
But This is what I run into.  I'm running the latest version of Coppermine and my upload.php file looks like this:

if(!empty($CONFIG['user_field1_name'])) {
            $form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field2_name'])) {
            $form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field3_name'])) {
            $form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field4_name'])) {
            $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
        }


The instruction say to look for:
array($CONFIG['user_field1_name'], 'user1', 0, 255, 1),
    array($CONFIG['user_field2_name'], 'user2', 0, 255, 1),
    array($CONFIG['user_field3_name'], 'user3', 0, 255, 1),
    array($CONFIG['user_field4_name'], 'user4', 0, 255, 1),
    );

and replace it with:

// Check for user defined fields.
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field". $i . "_name";
$uI = "user" . $i;
if(!empty($CONFIG[$uFN]))
{
$form_array[] = array($CONFIG[$uFN], $uI, 0, 255, 1);
}
}


I've tried it and I get a blank screen when upload.php tries to run.
The code is not the same but it is similar, there has to be someway to code it, but I'm like code stupid.

Any help is greatly appreciated.

Thanks,

Bryan

Nibbler


bgrega

The only way I could get it to work was to continue the code on like it was originally.
if(!empty($CONFIG['user_field6_name'])) {
            $form_array[] = array($CONFIG['user_field6_name'], 'user6', 0, 255, 1);
        }
etc........


Thanks,

Bryan

Nibbler

You need to post the code that doesn't work so we can tell you why it doesn't work.

bgrega

Sorry,  I must not have explained it properly.
I'm suppossed to be looking in my upload.php code for code that looks like thisarray($CONFIG['user_field1_name'], 'user1', 0, 255, 1),
    array($CONFIG['user_field2_name'], 'user2', 0, 255, 1),
    array($CONFIG['user_field3_name'], 'user3', 0, 255, 1),
    array($CONFIG['user_field4_name'], 'user4', 0, 255, 1),
    );

Unfortunately I can't find the code I'm supposed to look for, the only thing that comes close to looking like what I'm supposed to replace is thisif(!empty($CONFIG['user_field1_name'])) {
            $form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field2_name'])) {
            $form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field3_name'])) {
            $form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field4_name'])) {
            $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
        }
I Have no idea how to replace this section of code as it is similar yet not the same, and I know that some how, it's doing the same thing, so I just added all the extra fields as opposed to letting the loop do it.
Hope that helps, as I stated I'm no coder, wish I was.

Thanks

Bryan

Kaeghl

I am having a related issue.

When an image is uploaded none of the user defined information is saved to the database.

Everything  else is fine.

If I go into the image information after the upload and add information to the user defined fields and update, it saves fine.

any ideas?

Kaeghl

the debug dump like looks like this
[19] => INSERT INTO cpg1410_pictures (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, user5,  pic_raw_ip, pic_hdr_ip, position) VALUES ('', '77', 'userpics/10001/', 'bigpiechart.JPG', '58979', '135721', '876', '624', '1224266517', '1', 'Admin','test1', 'test2', 'test3', 'YES', '', '', '', '', '',  '10.222.202.159', '10.222.202.159', '0') (0.003s)



POST :
------------------
Array
(
    [album] => 77
    [title] => test1
    [caption] => test2
    [keywords] => test3
    [control] => phase_2
    [unique_ID] => ff749777
    [user1] => test4
    [user2] => test5
    [user3] => test6
    [user4] => test7
    [user5] => test8
    [debugtext] => USER:
------------------