Category/Album Jump Category/Album Jump
 

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

Category/Album Jump

Started by just_some_guy, November 13, 2007, 06:27:39 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

just_some_guy

Category/Album Jump
CPG 1.4x
DEMO

This is a new way to navigate your gallery. This creates a dropdown menu with a list of either categories or albums. The dropdown is the same as the one for choosing a theme or language (using coppermines built in JavaScript). It very easy to use and you can activate it by pasting the code below into a new file (say jump.php) and then in your gallery config navigate to the include of a custom header/footer and type jump.php - Simple.

For Category Jump -

<?php
// Start Coppermines code
echo "<form name=\"cpgChooseLanguage\" id=\"cpgChooseLanguage\" action=\"index.php\" method=\"get\" style=\"margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;display:inline\">";
echo 
"<select name=\"cpgLanguageSelect\" class=\"listbox_lang\" onchange=\"if (this.options[this.selectedIndex].value) window.location.href='index.php?cat=' + this.options[this.selectedIndex].value;\">";
// End Coppermines code
echo '<option selected>Category Jump</option>';

$sql "SELECT * FROM {$CONFIG['TABLE_CATEGORIES']}";
$result cpg_db_query($sql);
while (
$row mysql_fetch_assoc($result)) {
$cid_mod $row['cid'];
$name_mod $row['name'];
echo 
"last ".$name_mod." by ".$cid_mod."";
echo 
'<option value="';
echo 
$cid_mod;
echo 
'">';
echo 
$name_mod;
echo 
'</option>';
}



echo 
'</select>';
echo 
'</form>';
?>


For Album Jump -

<?php
// Start Coppermines code
echo "<form name=\"cpgChooseLanguage\" id=\"cpgChooseLanguage\" action=\"index.php\" method=\"get\" style=\"margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;display:inline\">";
echo 
"<select name=\"cpgLanguageSelect\" class=\"listbox_lang\" onchange=\"if (this.options[this.selectedIndex].value) window.location.href='thumbnails.php?album=' + this.options[this.selectedIndex].value;\">";
// End Coppermines code
echo '<option selected>Album Jump</option>';

$sql "SELECT * FROM {$CONFIG['TABLE_ALBUMS']}";
$result cpg_db_query($sql);
while (
$row mysql_fetch_assoc($result)) {
$cid_mod $row['aid'];
$name_mod $row['title'];
echo 
"last ".$name_mod." by ".$cid_mod."";
echo 
'<option value="';
echo 
$cid_mod;
echo 
'">';
echo 
$name_mod;
echo 
'</option>';
}



echo 
'</select>';
echo 
'</form>';
?>




I would like to hear your feedback,

Thanks,

just_some_guy
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Steve-R

Installed, tested and working well..Great addition and will be handy for many I'm sure. Especially for people like your sefl who have many categories on their site or many albums.

Simple install...

Steve...:)

just_some_guy

Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Joachim Müller

I appreciate the effort and your readiness to share your mods with the community. However this mod has some serious drawbacks.
I told you before already: don't run queries against the database for stuff that already exists using Coppermine's buillt-in functions: your query will not respect permissions at all. Subsequently, users will use the dropdown to navigate somewhere and all they will see is a message that tells them that they're not allowed to see that page. Additionally, the albums will not be within the proper order nor will they be sorted by category. You might want to look at frogfoot's approach for a dropdown list which is much better.

Mod needs improvement.

just_some_guy

Ouch, that hurt. When you say the query already exists in coppermine's functions; what is it?  i made the change of using cpg_db_quey instead of mysql_query. But im not sure of the function you are talking about.

Thanks for the advice and i will make sure to improve it ASAP.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Joachim Müller

Take a look at include/functions.inc.php - there are already functions that will return what you need, e.g. /**************************************************************************
   Functions for album/picture management
**************************************************************************/

// Get the list of albums that the current user can't see

/**
* get_private_album_set()
*
* @param string $aid_str
* @return
**/

function get_private_album_set($aid_str="")

Gephri

Hey just_some_guy - don't leave hurt!
Any thoughts of updating your Mod based on Müller's suggestions?

just_some_guy

It sort of went of the "to-do" list, but i may put some more thought into it.

Apologies for the delay,
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

skmdd

Quote from: Joachim Müller on November 13, 2007, 07:11:43 PM
I appreciate the effort and your readiness to share your mods with the community. However this mod has some serious drawbacks.
I told you before already: don't run queries against the database for stuff that already exists using Coppermine's buillt-in functions: your query will not respect permissions at all. Subsequently, users will use the dropdown to navigate somewhere and all they will see is a message that tells them that they're not allowed to see that page. Additionally, the albums will not be within the proper order nor will they be sorted by category. You might want to look at frogfoot's approach for a dropdown list which is much better.

Mod needs improvement.

I used frogfoot's approach he has used in searchnew.php to rewrite this mod. The page below draws a dropdown just like batch add page, but with a javascript which jumps to album on selection.
I want to include this dropdown on every page. I would like it to be included just below language dropdown. Where should I insert this code?


<?php
define
('IN_COPPERMINE'true);
define('DB_INPUT_PHP'true);

require(
'include/init.inc.php');
pageheader('DecoratingDesktop.com');

function 
albumselect($id "album") {
// frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order

    
global $CONFIG$lang_search_new_php$cpg_udb;
    static 
$select "";

    
// Reset counter
    
$list_count 0;

    if (
$select == "") {
        
$result cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0");
        while (
$row mysql_fetch_array($result)) {
            
// Add to multi-dim array for later sorting
            
$listArray[$list_count]['cat'] = $lang_search_new_php['albums_no_category'];
            
$listArray[$list_count]['aid'] = $row['aid'];
            
$listArray[$list_count]['title'] = $row['title'];
            
$list_count++;
        }
        
mysql_free_result($result);

        
$result cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname FROM {$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category < '" FIRST_USER_CAT "'");
        while (
$row mysql_fetch_array($result)) {
            
// Add to multi-dim array for later sorting
            
$listArray[$list_count]['cat'] = $row['cname'];
            
$listArray[$list_count]['aid'] = $row['aid'];
            
$listArray[$list_count]['title'] = $row['title'];
            
$list_count++;
        }
        
mysql_free_result($result);

        
//if (defined('UDB_INTEGRATION')) {
            
$sql $cpg_udb->get_batch_add_album_list();
        
/*} else {
            $sql = "SELECT aid, CONCAT('(', user_name, ') ', title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id)";
        }*/
        
$result cpg_db_query($sql);
        while (
$row mysql_fetch_array($result)) {
            
// Add to multi-dim array for later sorting
            
$listArray[$list_count]['cat'] = $lang_search_new_php['personal_albums'];
            
$listArray[$list_count]['aid'] = $row['aid'];
            
$listArray[$list_count]['title'] = $row['title'];
            
$list_count++;
        }
        
mysql_free_result($result);

        
$select '<option value="0"> Go to album... </option>\n';

        
// Sort the pulldown options by category and album name
        
$listArray array_csort($listArray,'cat','title');

        
// Create the nicely sorted and formatted drop down list
        
$alb_cat '';
        foreach (
$listArray as $val) {
            if (
$val['cat'] != $alb_cat) {
          if (
$alb_cat$select .= "</optgroup>\n";
                
$select .= '<optgroup label="' $val['cat'] . '">' "\n";
                
$alb_cat $val['cat'];
            }
            
$select .= '<option value="' $val['aid'] . '"' . ($val['aid'] == $sel_album ' selected' '') . '>   ' $val['title'] . "</option>\n";
        }
        if (
$alb_cat$select .= "</optgroup>\n";
    }

    return 
"\n<select name=\"$id\" class=\"listbox\" onchange=\"window.location.href='thumbnails.php?album='+this.value;\">\n$select</select>\n";
}

print 
albumselect();

pagefooter();
?>