coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: Shane on August 15, 2010, 10:29:56 PM

Title: Truncate Album Description problem with 1.5.x
Post by: Shane on August 15, 2010, 10:29:56 PM
site:  http://philmontforum.com/cpg

I am attempting to update the mod found at http://forum.coppermine-gallery.net/index.php/topic,40315.msg191082.html#msg191082 so it will work with my 1.5.x install.

I have made all of the changes needed to my theme.php file.  The truncation of the album description on the album list pages works perfectly.  I have the mod set to truncate album description to 120 characters.  Example - http://philmontforum.com/cpg/index.php?cat=10062

BUT... when I go to the thumbnail view for each album, the code returns the dreaded "Album not found"... Example - http://philmontforum.com/cpg/thumbnails.php?album=24

The code that returns "Album not found" is
// Get the name of an album
function get_album_desc($aid)
{
    global $CONFIG;
    global $lang_errors;
    $result = cpg_db_query("SELECT description from {$CONFIG['TABLE_ALBUMS']} WHERE aid='$aid'");
    $count = mysql_num_rows($result);
    if ($count > 0) {
        $row = mysql_fetch_array($result);
        return bb_decode($row['description']);
    } else {
        return "Album not found";
    }
}


I'm not a coder and have reached my limit of tinkering with this code.  Can anyone lead me in the right direction to make this code return the complete album description?

Thanks!
Title: Re: Truncate Album Description problem with 1.5.x
Post by: Shane on August 17, 2010, 01:36:32 PM
I haven't given up...

I changed the code to find out exactly what the $result variable returned:
// Get the name of an album
function get_album_desc($aid)
{
    global $CONFIG;
global $lang_errors;
    $result = cpg_db_query("SELECT description from {$CONFIG['TABLE_ALBUMS']} WHERE aid='$aid'");
    //$count = mysql_num_rows($result);
    //if ($count > 0) {
        //$row = mysql_fetch_array($result);
        return bb_decode($result);
    //} else {
        //return "Album description should load here but the code is not working";
    //}
}


This code returned the text "Resource id #204".  Screenshot is attached.  I have also included a shot from mysqladmin showing part of the row of data for this album.

It appears that the query above is not retrieving the album description for some reason.

Title: Re: Truncate Album Description problem with 1.5.x
Post by: Shane on August 18, 2010, 01:21:37 AM
Looking at the debug for both the album list page and the thumbnail view page, the query shows as

SELECT description from cpg1412_albums WHERE aid = ''

So... the album id ($aid) is not being sent in the query to grab the description.

I looked through the sample theme.php for other instances where the query is looking at the $aid, and I tried the code with the line formatted similarly (taking the ' from around the variable...
$result = cpg_db_query("SELECT description from {$CONFIG['TABLE_ALBUMS']} WHERE aid = $aid");
but this returns a mysql fatal error.

Any ideas?
Title: Re: Truncate Album Description problem with 1.5.x
Post by: Nibbler on August 18, 2010, 10:03:15 PM
You need to change


$album_desc = get_album_desc($_GET[album]);


to


$album_desc = get_album_desc($superCage->get->getInt('album'));


This is due to changes introduced in 1.5 (http://documentation.coppermine-gallery.net/en/dev_superglobals.htm)
Title: Re: Truncate Album Description problem with 1.5.x
Post by: Shane on August 19, 2010, 03:18:58 AM
Thanks a ton Nibbler!  ;D  I really appreciate it.  I'm slowly learning a bit of coding from all of this tinkering, but I don't think I'd ever have figured this one out.

I have now read that documentation, and will try to learn how to use it for future tinkering.

Shane