I want to somehow modify the "Select Album" from the "util.php" to allow me to select a album I want to jump to but not sure where I would start.
This are the code from the "util.php" that would generate the drop down list but know sure where to modify.
Code from the file that would show the Select Album
starttable('100%', $lang_util_php['select_album']);
echo '<tr><td class="tablef"><br />';
//if (defined('UDB_INTEGRATION')){
$cpg_udb->util_filloptions();
/*} else {
filloptions();
}*/
echo '<br /></td></tr>';
endtable();
then here is the function that generate the list:
function filloptions()
{
global $CONFIG, $lang_util_php;
$result = cpg_db_query("SELECT aid, category, IF(user_name IS NOT NULL, CONCAT('(', user_name, ') ',title), CONCAT(' - ', title)) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "LEFT JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id) " . "ORDER BY category, title");
echo ' <select size="1" name="albumid" class="listbox"><option value="0">All Albums</option>';
while ($row = mysql_fetch_array($result)){
$result2 = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = {$row['category']}");
$row2 = mysql_fetch_assoc($result2);
echo "<option value=\"{$row['aid']}\">{$row2['name']} {$row['title']}</option>";
}
echo '</select> (3) <input type="submit" value="'.$lang_util_php['submit_form'].'" class="button" /> (4)';
}
How would I modify it should that i will have this in the anycontent.php so that a user can select the album and click the submit button and it would jump to that album.
I am looking through the code and this code
echo "<option value=\"{$row['aid']}\">{$row2['name']} {$row['title']}</option>";
And it already has the Album ID there
So how would I modify
echo '</select> (3) <input type="submit" value="'.$lang_util_php['submit_form'].'" class="button" /> (4)';
So that when I click Submit it takes me to the album with the album ID from the selected album.
Okay I got it to look like this
http://www.ehmongmusic.com
with this:
<?php
starttable('100%', $lang_util_php['select_album']);
echo '<tr><td class="tablef">';
filloptions();
echo '</td></tr>';
endtable();
function filloptions()
{
global $CONFIG, $lang_util_php;
$result = cpg_db_query("SELECT aid, category, IF(user_name IS NOT NULL, CONCAT('(', user_name, ') ',title), CONCAT(' - ', title)) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "LEFT JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id) " . "ORDER BY category, title");
echo '<form action="thumbnails.php"><select size="1" name="album" class="listbox"><option value="0">All Albums</option>';
while ($row = mysql_fetch_array($result)){
$result2 = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = {$row['category']}");
$row2 = mysql_fetch_assoc($result2);
echo "<option value=\"{$row['aid']}\">{$row2['name']} {$row['title']}</option>";
}
echo '</select><input type=submit value="submit"></form>';
}
?>
But is is possible to make it look like the one from the Admin Tools Page but works like the one above?
Okay I got it solved now.
By using the album select code from the searchnew.php file.
function albumselect() {
// 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 = "";
$id = "album";
// 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">' . "Select An Album to Go To" . "</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<form action=\"thumbnails.php\"><select name=\"$id\" class=\"listbox\">\n$select</select><input type=\"submit\" value=\"GO TO\"/></form>\n";
}
That is the function and I just use
echo albumselect();
my in anycontent.php to show the code on my page.
here is what it looks like:
http://www.ehmongmusic.com
Cool! THis is what I am looking to do but I dont really get what you did. Did you edit the searchnew and util.php files? Where do you put echo albumselect();
I looked in the anycontent.php file but I dont get it. I was hoping to have a dropdown album selector in my {SYS_MENU}. Do you have any idea how I could put this in there?