Announcement

#1 2010-06-02 13:21:25

Gust
Member
2010-06-02
77

showing last 5 albums on external page

How can you automatelly show the last 5 photo albums on an external page?

Offline

 

#2 2010-06-02 13:39:01

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: showing last 5 albums on external page

See [Forum, topic 16011] How to display pics from a different page?
I'm afraid there is no ready-made solution at the moment, except for WordPress. But you can develop a plugin, if you feel like it.

Last edited by tosca (2010-06-02 13:40:07)


My galleries : Photos, Watercolours, Recipes

Offline

 

#3 2010-06-02 13:42:49

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13821

Re: showing last 5 albums on external page

As tosca said there is no "ready-made solution at the moment" but everything is ready at Piwigo level to provide this data to an external script.

Piwigo provides a web API with methods such as pwg.categories.getList. An external script can perform a request on the Piwigo API and then compute data to display the last 5 albums for example.

Maybe we can help you to achieve this. What is the programming language of your "external page"?

Offline

 

#4 2010-06-02 13:48:21

Gust
Member
2010-06-02
77

Re: showing last 5 albums on external page

plg wrote:

Maybe we can help you to achieve this. What is the programming language of your "external page"?

the programming language is PHP.

Please, visit this test website. You see a starting page with
- last 5 news messages
- last activities
- last CD's
- and now... last 5 photo albums

If you clicked on a photo album, you must simply go tho that photo album.

Please, I hope you can achieve this. I'm looking for a long time a system like this, and I think mutch members looking for an "last x albums"-system

Last edited by Gust (2010-06-02 13:55:58)

Offline

 

#5 2010-06-02 14:35:59

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13821

Re: showing last 5 albums on external page

Quickly coded (the most difficult is the fetchRemote function which comes from Piwigo code):

Code:

$url = "http://piwigo.org/demo/ws.php?method=pwg.categories.getList&format=php&recursive=true&public=true";
fetchRemote($url, $result);
$result = unserialize($result);
$categories = $result['result']['categories'];

foreach ($categories as $idx => $category) {
  $date_last[$idx] = $category['date_last'];
}

array_multisort($date_last, SORT_DESC, $categories);
$categories = array_slice($categories, 0, 5);

echo '<ul>';
foreach ($categories as $category) {
  echo(
    sprintf(
      '<li><a href="%s">%s</a></li>',
      $category['url'],
      $category['name']
      )
    );
}
echo '</ul>';

demo : http://piwigo.org/tmp/last5albums.php
source : http://piwigo.org/tmp/last5albums.phps

Offline

 

#6 2010-06-02 14:51:15

Gust
Member
2010-06-02
77

Re: showing last 5 albums on external page

Thanks!

But... I mean actually a picture of an album, with the name of the album below the picture

Example:
http://www.folkinlimburg.be/images/last5images.jpg

Offline

 

#7 2010-06-02 15:05:06

Arturo
Guest

Re: showing last 5 albums on external page

Gust wrote:

Thanks!

But... I mean actually a picture of an album, with the name of the album below the picture

Example:
http://www.folkinlimburg.be/images/last5images.jpg

I meant the same as Gust, just in my case I do not need the names below, just the thumbnails!

 

#8 2010-06-02 15:07:29

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: showing last 5 albums on external page

I guess plg will give you the name of the variable to get the thumbnail too.
As for the layout (or hiding of some information) you can tune it using a CSS style sheet.

Last edited by tosca (2010-06-02 15:08:14)


My galleries : Photos, Watercolours, Recipes

Offline

 

#9 2010-06-02 15:09:31

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13821

Re: showing last 5 albums on external page

Unfortunately, getting the thumbnail requires a bit more lines of code (because pwg.categories.getList doesn't return a thumbnail src (not yet). I will have to perform another 5 HTTP requests to get a random thumbnail for each album, would that be OK?

Offline

 

#10 2010-06-02 15:59:47

Gust
Member
2010-06-02
77

Re: showing last 5 albums on external page

You mean the last 5 albums appear with a random image? That is even better!

Offline

 

#11 2010-06-02 22:04:07

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13821

Re: showing last 5 albums on external page

I have updated the script

demo : http://piwigo.org/tmp/last5albums.php
source : http://piwigo.org/tmp/last5albums.phps

Now it shows the 5 last updated albums + a random thumbnail for each one.

Offline

 

#12 2010-06-02 22:09:17

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: showing last 5 albums on external page

Great! I might use this one on my blog.


My galleries : Photos, Watercolours, Recipes

Offline

 

#13 2010-06-02 23:54:02

Gust
Member
2010-06-02
77

Re: showing last 5 albums on external page

That 's perfect! Thanks man!!!

Offline

 

#14 2010-06-03 11:35:31

Gust
Member
2010-06-02
77

Re: showing last 5 albums on external page

The "$category" in the script give a conflict with Cutenews, a familiar news script. Is it possible to give an alternative name for $category?

In the box of Cutenews, I see this:

-----------------------
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/vhosts/folkinlimburg.be/httpdocs/nieuws/show_news.php on line 58
Error!
CuteNews detected that your $ category = "", but you can use only the categories with their ID number calls but not name

Example:

<?PHP
$category = "1";
include("path/to/show_news.php");
?>
-----------------------

Please, look at this test website

Offline

 

#15 2010-06-03 23:47:52

Arturo
Guest

Re: showing last 5 albums on external page

plg wrote:

I have updated the script

demo : http://piwigo.org/tmp/last5albums.php
source : http://piwigo.org/tmp/last5albums.phps

Now it shows the 5 last updated albums + a random thumbnail for each one.

EXCELLENT...YOU ARE THE BEST!!!

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact