How can you automatelly show the last 5 photo albums on an external page?
Offline
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)
Offline
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
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
Quickly coded (the most difficult is the fetchRemote function which comes from Piwigo 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
Thanks!
But... I mean actually a picture of an album, with the name of the album below the picture
Example:
Offline
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!
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)
Offline
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
You mean the last 5 albums appear with a random image? That is even better!
Offline
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
Great! I might use this one on my blog.
Offline
That 's perfect! Thanks man!!!
Offline
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
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!!!