XP Publish - Nicer Select Boxes XP Publish - Nicer Select Boxes
 

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

XP Publish - Nicer Select Boxes

Started by philipmatarese, September 11, 2006, 10:38:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

philipmatarese

One of the screens in CPG 1.4.9 has a drop down for all albums that uses the OPTGROUP tag to seperate them into categories.  I've done the same thing in the XP Publishing screens.  All of my users are admins, so I don't know if the user part works.

All changes are to xp_publish.php.



First, the queries must return the categories and be sorted by them primarily.

Find this code (Admin):
        $public_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category < " . FIRST_USER_CAT . " ORDER BY title");
Change to this code:
        $public_albums = cpg_db_query("SELECT alb.aid, cat.name, alb.title FROM {$CONFIG['TABLE_ALBUMS']} alb INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cat ON category = cid WHERE category < " . FIRST_USER_CAT . " ORDER BY cat.name, alb.title");

Find this code (User):
        $user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='" . (FIRST_USER_CAT + USER_ID) . "' ORDER BY title");
Change to this code:
        $public_albums = cpg_db_query("SELECT alb.aid, cat.name, alb.title FROM {$CONFIG['TABLE_ALBUMS']} alb INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cat ON category = cid WHERE category = " . (FIRST_USER_CAT + USER_ID) . " ORDER BY cat.name, alb.title");



Now, display the OPTGROUP tags for each category of albums.

Find this code:
    $html = "\n";
    foreach($user_albums_list as $album) {
        $html .= '                        <option value="' . $album['aid'] . '">* ' . $album['title'] . "</option>\n";
    }
    foreach($public_albums_list as $album) {
        $html .= '                        <option value="' . $album['aid'] . '">' . $album['title'] . "</option>\n";
    }

Change to this code:
    $html = "\n";
    $last_cat = "";
    foreach($user_albums_list as $album) {
        if ($last_cat != $album['name']) {
            $html .= '                        <optgroup label="' . $album['name'] . '">';
            $last_cat = $album['name'];
        }
        $html .= '                        <option value="' . $album['aid'] . '">* ' . $album['title'] . "</option>\n";
    }
    foreach($public_albums_list as $album) {
        if ($last_cat != $album['name']) {
            $html .= '                        <optgroup label="' . $album['name'] . '">';
            $last_cat = $album['name'];
        }
        $html .= '                        <option value="' . $album['aid'] . '">' . $album['title'] . "</option>\n";
    }


Enjoy.

Joachim Müller


philipmatarese

There are only 4 of us sharing the website.

philipmatarese

Ok.  I just read the link you posted (dumb me - reply first read post later) and it's a good point.  I guess I should figure out how to let them have the same functionality as users instead of admins.

Thanks for getting my attention.