forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: anna. on October 09, 2008, 03:42:36 am

Title: Last updated albums
Post by: anna. on October 09, 2008, 03:42:36 am
I hate doing new topics because I feel like the answer is out there and I missed it even though I've searched, read and tried lots of things with no success, so I hope you can help me with this. I'm not very good with php so maybe that's why I haven't succeded :/

What I want to do is show the last updated albums, I'm using listMediaAddedOverLastDays but obviously if I don't updated the gallery for a certain number of days the list disappear and if I put more days it'll show a long list of updated albums. Is it possible to just show a certain number of last updated albums (or last added media)?
Title: Re: Last updated albums
Post by: anna. on October 23, 2008, 04:58:23 am
ok, since there was no answer I had to venture myself into this even more, and after so many days and hours of reserching and trial and error I managed to get what I wanted, I'll post it here so others can see it and use it if they want.

I first changed in cpmfetch_dao.php this:
Code: [Select]
function getMediaAddedSince ($timestamp) {
$retval = "";
if (is_numeric($timestamp)) {
$sqlcode = 'SELECT ' . $this->sqlSelect
. ', c.name AS cName, count( p.pid ) AS count '
. ' FROM '
. $this->sqlTableSelect
// . " WHERE p.aid = a.aid AND a.category = c.cid "
. " WHERE a.category = c.cid "
. $this->sqlUserDataLink
. " AND p.approved='YES' $this->privacyfilter AND p.ctime > " . $timestamp
. ' GROUP BY a.category, a.aid'
. ' ORDER BY c.name, p.mtime';

$retval = $this->dbExecuteSql($sqlcode);
}

return($this->covertResultsetToArray($retval));
}
into this:
Code: [Select]
function getMediaAddedSince ($timestamp) {
$retval = "";
if (is_numeric($timestamp)) {
$sqlcode = 'SELECT ' . $this->sqlSelect
. ', c.name AS cName, count( p.pid ) AS count '
. ' FROM '
. $this->sqlTableSelect
// . " WHERE p.aid = a.aid AND a.category = c.cid "
. " WHERE a.category = c.cid "
. $this->sqlUserDataLink
. " AND p.approved='YES' $this->privacyfilter AND p.ctime > " . $timestamp
. ' GROUP BY a.category, a.aid'
. ' ORDER BY p.ctime DESC';

$retval = $this->dbExecuteSql($sqlcode);
}

return($this->covertResultsetToArray($retval));
}

So it shows/lists the albums last updated/created and not by alphabetic order.

and then this is the code I used to show the list:

Code: [Select]
<?php
include "./photos/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./photos/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setReturnType("resultset");
$data $objCpm->cpm_showAlbumsUpdatedOverLastDays(100);

$cnt 0;
$albumstoshow 5;
$arrayofalbums = array();

foreach ($data as $row) {
if (! in_array($row['aTitle'],$arrayofalbums)) {
print "<table><tr>";
print "<td>";
print "<a href=\"/photos/displayimage.php?pos=-{$row['pPid']}\" target=\"_blank\"><img src=\"/photos/albums/{$row['pFilepath']}/thumb_{$row['pFilename']}\" width=\"40\"></A>";
print "</td>";
print "<td>";
print "<b>{$row['count']}</b> new pictures in<br><a href=\"/photos/thumbnails.php?album={$row['pAid']}\" target=\"_blank\">";
print $row['aTitle']. "</a><br>\n";
print "</td>";
print "</tr></table>";
array_push($arrayofalbums,$row['aTitle']);
$cnt++;
if ($cnt == $albumstoshow) break;
}
}
$objCpm->cpm_close();
?>




Maybe there's and easy way, or this is not completely right but it works for me, so yeah. You can see how it looks here: http://canon-love.co.uk/ (on the left sidebar)
Title: Re: Last updated albums
Post by: phileuf on October 31, 2008, 09:04:55 am
Great...

Your post is very important for me.

I understand the first part, but I don't known where you put the second code for showing the pictures.

Thanks for your help

PS: sorry for my poor english  ;)
Title: Re: Last updated albums
Post by: phileuf on October 31, 2008, 09:07:07 am
My problem is, perhaps, because I work with Joomla (with medhi's bridge, of course) ?
Title: Re: Last updated albums
Post by: phileuf on October 31, 2008, 01:19:40 pm
It's ok...

With the module nammed Jumi (http://jumi.vedeme.cz), I can put php in Joomla  ;D

Bye
Title: Re: Last updated albums
Post by: Joachim Müller on October 31, 2008, 03:35:08 pm
You might want to read the board rules and the sticky threads to figure out why nobody will reply to your postings. Locking