Advanced search  

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]

Pages: 1 [2] 3   Go Down

Author Topic: Add More Custom Fields via Config  (Read 49962 times)

0 Members and 1 Guest are viewing this topic.

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: Add More Custom Fields via Config
« Reply #20 on: May 26, 2006, 04:54:53 pm »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Add More Custom Fields via Config
« Reply #21 on: May 27, 2006, 10:13:52 am »

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

Dr Preacox

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 122
  • Is the Matrix...
    • Dynamic Creations
Re: Add More Custom Fields via Config
« Reply #22 on: May 28, 2006, 10:50:51 am »

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

flar

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Add More Custom Fields via Config
« Reply #23 on: May 28, 2006, 12:01:55 pm »

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.
Logged

flar

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Add More Custom Fields via Config
« Reply #24 on: May 28, 2006, 12:20:43 pm »

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?
Logged

Dr Preacox

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 122
  • Is the Matrix...
    • Dynamic Creations
Re: Add More Custom Fields via Config
« Reply #25 on: May 29, 2006, 05:11:11 pm »

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

(http://www.dc-6.com/drpreacox/idea.jpg)

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.
Logged
My Mods:
Making Memberlist Public - VIEW
Different Way of Displaying Categories - VIEW
Coming Soon - Automated Sub Domains -MOD

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Add More Custom Fields via Config
« Reply #26 on: May 29, 2006, 08:03:05 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.
Logged

dbh123

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Add More Custom Fields via Config
« Reply #27 on: June 01, 2006, 09:12:59 am »

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

Code: [Select]
$userFields[]=$_POST['user$i'];
in editOnePic.php (around line 45) should have been:

Code: [Select]
$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.



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
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: Add More Custom Fields via Config
« Reply #28 on: July 08, 2006, 07:41:43 pm »

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.
Logged

lemonlime

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Add More Custom Fields via Config
« Reply #29 on: November 04, 2007, 05:19:08 pm »

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.

Logged

pcinfoman

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
Re: Add More Custom Fields via Config
« Reply #30 on: January 10, 2008, 06:42:16 pm »

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?
Logged

Nibbler

  • Guest
Re: Add More Custom Fields via Config
« Reply #31 on: January 10, 2008, 07:10:33 pm »

Code: [Select]
ALTER TABLE cpg14x_pictures ADD user5 VARCHAR(255)
or use a GUI like phpmyadmin.
Logged

pcinfoman

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
Re: Add More Custom Fields via Config
« Reply #32 on: January 11, 2008, 06:40:20 pm »

Code: [Select]
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..
Logged

bgrega

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Add More Custom Fields via Config
« Reply #33 on: September 30, 2008, 03:59:53 am »

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:
Code: [Select]
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:
Code: [Select]
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
Logged

Nibbler

  • Guest
Re: Add More Custom Fields via Config
« Reply #34 on: September 30, 2008, 06:26:46 pm »

Zip up and attach your upload.php.
Logged

bgrega

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Add More Custom Fields via Config
« Reply #35 on: October 01, 2008, 05:03:14 pm »

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

Thanks,

Bryan
Logged

Nibbler

  • Guest
Re: Add More Custom Fields via Config
« Reply #36 on: October 01, 2008, 07:36:09 pm »

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

bgrega

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Add More Custom Fields via Config
« Reply #37 on: October 02, 2008, 03:04:50 pm »

Sorry,  I must not have explained it properly.
I'm suppossed to be looking in my upload.php code for code that looks like this
Code: [Select]
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),
    );
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 this
Code: [Select]
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);
        }
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
Logged

Kaeghl

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Add More Custom Fields via Config
« Reply #38 on: October 17, 2008, 08:06:32 pm »

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?
Logged

Kaeghl

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Add More Custom Fields via Config
« Reply #39 on: October 17, 2008, 08:08:51 pm »

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:
------------------
Logged
Pages: 1 [2] 3   Go Up
 

Page created in 0.032 seconds with 20 queries.