Advanced search  

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]

Pages: [1] 2   Go Down

Author Topic: Latest updated albums on a website  (Read 15835 times)

0 Members and 1 Guest are viewing this topic.

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Latest updated albums on a website
« on: March 29, 2016, 05:35:07 am »

Hi. Soryr if this is in the wrong place, I wasn't sure if this was to go under plugins, bridges, or something else.

Anyway, I wanted to display the latest updated albums from my gallery on my site. I thought I'd found a way to do that, but it actually shows only the last albums that were created.
This is the code I have:

Code: [Select]
<?php
require_once(
'include/config.inc.php');
header("Content-type: application/x-javascript");

$connect mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass'])
or die('Error connecting to the server');
$connect_db mysql_select_db($CONFIG['dbname'], $connect)
or die ('Error connecting to the database');
$resultado mysql_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 12"$connect)
or die('No albums found with this query');    
echo 'document.write(\'';
if(mysql_num_rows($resultado) == 0){
echo 'No albums created';
} else {
echo '<div class="wrapper"><ul>';
while($row mysql_fetch_array($resultado)){
echo ' ';
$album_id $row['aid'];
$subresult mysql_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 12");

if(mysql_num_rows($subresult) == 0){
$album_img "GALLERY URL/thumbs/thumb_nopic.png";
} else {
while($subrow mysql_fetch_array($subresult)){
$album_img "GALLERY URL/albums/".$subrow['filepath'].'thumb_'.$subrow['filename']  .$subrow['datebrowse'];                             
}
}
echo '<li><div class="albimg"><img src="'.$album_img.'" alt="" /><div class="galtit"><a href="http://stanakaticbrasil.com./galteste/thumbnails.php?album='.$album_id.' ">'.$row['title'].'</a></div></div></li>';
echo '';
}
}
echo '</ul></div>';
echo '\');';
?>

Is there something I can change in this code to get the output I want?
Thank you.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #1 on: March 29, 2016, 09:58:27 am »

Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Latest updated albums on a website
« Reply #2 on: March 29, 2016, 11:48:55 pm »

Sorry if I'm being dumb/blind, but I just went through 4 pages of that thread and didn't find it in a single place saying how to get cpmfetch do display albums instead of images.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #3 on: March 30, 2016, 12:00:52 am »

I see in cpmfetch

Code: [Select]
function cpm_viewLastUpdatedAlbumsFrom

Let me test it on my test gallery.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #4 on: March 30, 2016, 12:41:24 am »

Add this in a .php file. Name it want you like and upload it the gallery root.

Code: [Select]
<?php
  
include "cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("cpmfetch/cpmfetch_config.php");
  
$objCpm->cpm_viewLastUpdatedAlbumsFrom(0,1,4);
  
$objCpm->cpm_close();
?>


Then use iframes to call the php file on your html pages.

Code: [Select]
<iframe src="your_path/your_php_file.php"></iframe>

If is a php file then you can paste the code in the page.
Change the paths to your cmpetch paths (cpmfetch/cpmfetch.php and cpmfetch/cpmfetch_config.php) with the right path.

You want to display title or the caption under too?

If the page you want to display the last up alb is not on the same domain as the gallery then you have to use iframes.

Look in cpmfetch.php for all the possible cmpfetch options like display random etc
« Last Edit: March 30, 2016, 01:04:27 am by allvip »
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Latest updated albums on a website
« Reply #5 on: March 30, 2016, 01:11:07 am »

Thank you!
Yes, I want album title as well.
One question: what each number ("(0,1,4)" ) stand for? Rows, columns and?
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #6 on: March 30, 2016, 01:14:49 am »

One question: what each number ("(0,1,4)" ) stand for? Rows, columns and?

0 is the cat id and I used 0 so will take the last from all cats.
1 row and 4 albums.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #7 on: March 30, 2016, 01:57:26 am »

Yes, I want album title as well.

You will have to search the forum for how to display the caption in cmpfetch or wait for the coppermine team to reply.
On my test it did not worked out. Don't know how.
Sorry.
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Latest updated albums on a website
« Reply #8 on: March 30, 2016, 04:54:24 am »

Thank you for trying though.
I think it might be easier to edit the code I had at first. I always had a hard time figuring cpmfetch out.

The current query has all albums to be displayed by album ID (aid) is descent order. So it returns the last created albums.

Code: [Select]
$resultado = mysql_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 12", $connect)
and

Code: [Select]
$album_id = $row['aid'];
$subresult = mysql_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 12");

I just can't seem to figure out what I should replace "aid" for. I couldn't find anything on cpg documentation. Any idea where I could find it (or what I can use to replace aid)?
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Latest updated albums on a website
« Reply #9 on: March 30, 2016, 05:39:51 am »

Look in include/functions.inc.php

Search for     

Code: [Select]
case 'lastalb': // Last albums to which files have been uploaded
and a little more down

Code: [Select]
// last uploaded file from album
The query is there.
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Latest updated albums on a website
« Reply #10 on: March 30, 2016, 06:38:37 am »

I tried that, but I keep getting a "No albums found with this query" as a result. I also tried with "ctime" and in different variations ("... ORDER BY `cpg_albums`.`ctime` DESC ..."; "... ORDER BY `cpg_albums`.`lastalb` DESC ...", "... ORDER BY `lastalb` DESC ...", and so on).
Does the $subresult need to be edited as well?

I'm really sorry, but I'm completely new in php, and I'm clearly over my head. =/
Logged

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 947
  • +Tinyportal Support team.
Re: Latest updated albums on a website
« Reply #11 on: March 30, 2016, 09:57:49 am »

Not sure all the functions work in cmpfetch, in fact I know some don't.  it was originally written for Coppermine 1.4.xx before it was retired.

I only use it to display random images and latest images on my front page as can be seen here http://cameracraniums.com

I haven't tried using it for anything else tbh.
Logged
Running SMF 2.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Re: Latest updated albums on a website
« Reply #12 on: March 30, 2016, 10:18:04 am »

Not sure all the functions work in cmpfetch, in fact I know some don't.  it was originally written for Coppermine 1.4.xx before it was retired.

I only use it to display random images and latest images on my front page as can be seen here http://cameracraniums.com

I haven't tried using it for anything else tbh.

How did you made it to make the title and views to show?

The code should be something like this (is working but the options not)

Code: [Select]
<?php
$options 
= array( 'subtitle' => 'Image %t is %S KB' 'imagewidth' => '200' );
  include 
"cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("cpmfetch/cpmfetch_config.php");
  
$objCpm->cpm_viewLastUpdatedAlbumsFrom(0,1,4,$options);
  
$objCpm->cpm_close();
?>


Where  %t should display the title and %S the file zise but only the 'imagewidth' => '200' is working.
What should be used for subtitle to make it display the image title?
Logged

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 947
  • +Tinyportal Support team.
Re: Latest updated albums on a website
« Reply #13 on: March 30, 2016, 06:39:47 pm »

You mean this bit?

Code: [Select]
$objCpm = new cpm();$options = array("subtitle" => "<center>{{pTitle}} <br> {{pHits}} Views  </center>");
Logged
Running SMF 2.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 947
  • +Tinyportal Support team.
Re: Re: Latest updated albums on a website
« Reply #14 on: March 30, 2016, 06:47:26 pm »

You mean this bit?  Remember I'm running my code in a Tinyportal PHP block.

Code: [Select]
$objCpm = new cpm();$options = array("subtitle" => "<center>{{pTitle}} <br> {{pHits}} Views  </center>");

When I used this cpmfetch in Coppermine 1.4.xx a few years ago I also had it showing the user name below each image, but that ceased to function in Coppermine 1.5.xx, and I never did discover how to get that bit working again. ;)
Logged
Running SMF 2.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Re: Latest updated albums on a website
« Reply #15 on: March 30, 2016, 07:01:02 pm »

You mean this bit?

Code: [Select]
$objCpm = new cpm();$options = array("subtitle" => "<center>{{pTitle}} <br> {{pHits}} Views  </center>");

Nothing shows.
Logged

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 947
  • +Tinyportal Support team.
Re: Re: Latest updated albums on a website
« Reply #16 on: March 30, 2016, 08:38:09 pm »

Nothing shows.

That's only part of the code I'm using. Are you running it in a portal block same as me?  If so there's my original code here, (the second one in that post) http://forum.coppermine-gallery.net/index.php/topic,65412.msg336985.html#msg336985

Or if you need my current code which shows both random and latest (in a portal block), I'll PM it to you. ;)
Logged
Running SMF 2.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Re: Re: Latest updated albums on a website
« Reply #17 on: March 30, 2016, 09:07:29 pm »

Are you running it in a portal block same as me?  If so there's my original code here, (the second one in that post) http://forum.coppermine-gallery.net/index.php/topic,65412.msg336985.html#msg336985

Or if you need my current code which shows both random and latest (in a portal block), I'll PM it to you. ;)

No. I created a php file in the gallery root. Your code is working but not the subtitle option.

The example from the docs (options subtitle not working)

Code: [Select]
<?php
  
include_once "cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("cpmfetch/cpmfetch_config.php");
  
$options = array("subtitle" => "File name : {{pFilename}}");
  
$objCpm->cpm_viewLastAddedMedia(14$options);
  
$objCpm->cpm_viewRandomMediaFrom(0,14$options);
  
$objCpm->cpm_close(); 
?>

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Latest updated albums on a website
« Reply #18 on: April 06, 2016, 11:59:53 am »

I think it might be easier to edit the code I had at first.

I think the main issue is the table prefix, which is probably different in your gallery than "cpg_". This worked for me, as it used the table prefix set in include/config.inc.php:
Code: [Select]
<?php
require_once(
'include/config.inc.php');
header("Content-type: application/x-javascript");

$connect mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass'])
or die('Error connecting to the server');
$connect_db mysql_select_db($CONFIG['dbname'], $connect)
or die ('Error connecting to the database');
$resultado mysql_query("SELECT * FROM `{$CONFIG['TABLE_PREFIX']}albums` ORDER BY `{$CONFIG['TABLE_PREFIX']}albums`.`aid` DESC LIMIT 0 , 12"$connect)
or die('No albums found with this query');    
echo 'document.write(\'';
if(mysql_num_rows($resultado) == 0){
echo 'No albums created';
} else {
echo '<div class="wrapper"><ul>';
while($row mysql_fetch_array($resultado)){
echo ' ';
$album_id $row['aid'];
$subresult mysql_query("SELECT * FROM `{$CONFIG['TABLE_PREFIX']}pictures` where aid=$album_id order by pid DESC LIMIT 0, 12");

if(mysql_num_rows($subresult) == 0){
$album_img "GALLERY URL/thumbs/thumb_nopic.png";
} else {
while($subrow mysql_fetch_array($subresult)){
$album_img "GALLERY URL/albums/".$subrow['filepath'].'thumb_'.$subrow['filename']  .$subrow['datebrowse'];                             
}
}
echo '<li><div class="albimg"><img src="'.$album_img.'" alt="" /><div class="galtit"><a href="http://stanakaticbrasil.com./galteste/thumbnails.php?album='.$album_id.' ">'.$row['title'].'</a></div></div></li>';
echo '';
}
}
echo '</ul></div>';
echo '\');';
?>
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Latest updated albums on a website
« Reply #19 on: April 06, 2016, 12:57:47 pm »

Actually, the code was working just fine, but it retrieves the last created albums, and I wanted the last updated albums.
I can't figure out what to change
Code: [Select]
ORDER BY `cpg_albums`.`aid` for to achieve that. I've tried a few different combinations of lastalb and ctime, but no such luck.

Thank you for trying though.
I think it might be easier to edit the code I had at first. I always had a hard time figuring cpmfetch out.

The current query has all albums to be displayed by album ID (aid) is descent order. So it returns the last created albums.

Code: [Select]
$resultado = mysql_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 12", $connect)
and

Code: [Select]
$album_id = $row['aid'];
$subresult = mysql_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 12");

I just can't seem to figure out what I should replace "aid" for. I couldn't find anything on cpg documentation. Any idea where I could find it (or what I can use to replace aid)?

I tried that, but I keep getting a "No albums found with this query" as a result. I also tried with "ctime" and in different variations ("... ORDER BY `cpg_albums`.`ctime` DESC ..."; "... ORDER BY `cpg_albums`.`lastalb` DESC ...", "... ORDER BY `lastalb` DESC ...", and so on).
Does the $subresult need to be edited as well?

I'm really sorry, but I'm completely new in php, and I'm clearly over my head. =/
Logged
Pages: [1] 2   Go Up
 

Page created in 0.047 seconds with 20 queries.