Adding Fields to the Album Config Adding Fields to the Album Config
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Adding Fields to the Album Config

Started by Blodlizrd, March 19, 2007, 04:55:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Blodlizrd

Hello, all.  I am very much a noob when it comes to PHP, so this is probably a very simple question... at least I hope it is.  :)  I am trying to add some more fields to the "Update Album" area of my site.  First, I modified the table "cpg1410_albums" and created a new TEXT entry called "scale".  I looked at the code for the modifyalb.php file and on row 47 I entered this:

   array($lang_modifyalb_php['alb_scale'], 'scale', 0),

Now when the page loads, I get a new text box to input data, but I don't know how to tell it to update the database under the "scale" entry.  Also, I don't know how to label that text box in the same way that "Album Title" and "Album Description" is labeled on that page.

Your help would be greatly appreciated.

Thanks so much.

Joachim Müller

Things are not that simple. You need to edit the database once. Then you'll need to come up with the forms and display results, and you'll have to come up with the changes in the queries. The language array you found is not related. Bottom line: unless you understand PHP and a bit of mySQL, you probably won't be able to accomplish this.
Why don't you instead post what you're actually trying to accomplish (describing things like "I want XXX to be displayed on the page YYY next to the page element ZZZ" when the user does this...")? Maybe there is already a mod that does what you're up to do.

Blodlizrd

Alrighty... I have a website that is about plastic models.  Users create albums and each of these albums are of one of the models they have built.  Since they post mutiple images of the same model, the album should contain information such as manufacturer, scale, date completed.  Ideally, I would like for someone to be able to click on the album and it would show thumbnails of all the pictures in the album listed down the left side and on the right have the information about the model described above along with the current album information. 

On a side note, and frankly what I was really hoping Coppermine would be able to do, I would like to be able to define categories and subcategories that people could assign to each album and users would be able to customize what types of models they saw.  As it is now, it looks as though I can create categories and then people can uplaod pictures to those categories, but they can not create subcategories in these in which to post their albums.

I may be asking to much, but that is my grand scheme.  :) 

Joachim Müller

Allow users to have personal galleries then.

JohannM

Blodlizrd

I have the same thing I want to do:

I can help you with some of the bits up to an end, but like you, I get stuck at a certain point, and I'm sure someone here (one of the clever blokes) will help us further.

Just to say:

I wanted to add the fields "Event Location" and "Event Date" to my Albums, since I don't really dig the idea as to copy and paste the usual stuff (Event venue and date) in there.  I manage to edit the database, the php pages I understand to be changed.

1.  I opened my MySQL panel, and went to the coppermine database and added the two line "event_location" and "event_date" to the sql quiry:

    Quote:

    CREATE TABLE cpg1410_albums (
  aid int(11) NOT NULL auto_increment,
  title varchar(255) NOT NULL default '',
  description text NOT NULL,
  event_location text NOT NULL,
  event_date text NOT NULL,
  event_new enum('YES','NO') NOT NULL default 'YES',
  visibility int(11) NOT NULL default '0',
  uploads enum('YES','NO') NOT NULL default 'NO',
  comments enum('YES','NO') NOT NULL default 'NO',
  votes enum('YES','NO') NOT NULL default 'NO',
  pos int(11) NOT NULL default '0',
  category int(11) NOT NULL default '0',
  thumb int(11) NOT NULL default '0',
  keyword VARCHAR( 50 ),
  alb_password VARCHAR( 32 ),
  alb_password_hint TEXT,
  PRIMARY KEY  (aid),
  KEY alb_category (category)
) TYPE=MyISAM COMMENT='Used to store albums';


Un-Quote

2.  Find in file db-input.php

    line 179:

    case 'album_update':
        if (!(USER_ADMIN_MODE || GALLERY_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
 
    and after:   $description = addslashes(trim($_POST['description']));

    add:  $event_location = addslashes(trim($_POST['event_location'])); //JOHANN ADDED
            $event_date = addslashes(trim($_POST['event_date'])); //JOHANN ADDED

    I also fixed this line (round about line 204): I added event_location and event_date

    if (GALLERY_ADMIN_MODE) {
       $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', event_location='$event_location',                    event_date='$event_date', event_new='$event_new', category='$category', thumb='$thumb', uploads='$uploads', comments='$comments', votes='$votes', visibility='$visibility', alb_password='$password', alb_password_hint='$password_hint', keyword='$keyword' WHERE aid='$aid' LIMIT 1";
        } else {



3.  In your language.php file:


     Find:  // File modifyalb.php

     And add:   

     'event_location' =>'Event Location', //JOHANN
     'event_date' =>'Event Date', //JOHANN


4.  In modifyalb.php

     Find: $captionLabel = $lang_modifyalb_php['alb_desc'];

     After: $data = array($lang_modifyalb_php['general_settings'],

     Add:    array($lang_modifyalb_php['event_location'], 'event_location', 0), //JOHANN ADDED
               array($lang_modifyalb_php['event_date'], 'event_date', 0), //JOHANN ADDED

5.  In my themes page (theme.php) i locate {ALB_DESC} and add a <br> and then {EVENT_LOCATION} wich is now suppose to reflect the data in the data base.

    Also in theme.php page on line 1798  I added the fields like this:

       if (is_array($alb_list)) {
        foreach($alb_list as $album) {
            $count ++;

            $params = array('{COL_WIDTH}' => $column_width,
                '{ALBUM_TITLE}' => $album['album_title'],
                '{THUMB_CELL_WIDTH}' => $thumb_cell_width,
                '{ALB_LINK_TGT}' => "thumbnails.php?album={$album['aid']}",
                '{ALB_LINK_PIC}' => $album['thumb_pic'],
                '{ADMIN_MENU}' => $album['album_adm_menu'],
                '{ALB_DESC}' => $album['album_desc'],
                '{EVENT_LOCATION}' => $album['event_location'],
                '{EVENT_DATE}' => $album['event_date'],
                '{ALB_INFOS}' => $album['album_info'],
                );




Now, when entering the data in the fields on my Abdate Album Page, it do post the data to the database correctly.  When I highlight them and delete them, and I do the "update", it also do the update in the database.

Where I'm stuck now is, the information does not show on the actual index.php page after going to the specific album.

Question now is how and where to fix it that it does reflect ?

Blodlizrd

Gau, I have allowed users to have personal galleries, but I want to further allow them to select a category and a subcategory for each album. 

Johann, I will look into your code further.  Thanks for the suggestion.