Truncate Album Description problem with 1.5.x Truncate Album Description problem with 1.5.x
 

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

Truncate Album Description problem with 1.5.x

Started by Shane, August 15, 2010, 10:29:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Shane

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!

Shane

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.


Shane

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?

Nibbler

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)

Shane

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