Pages: 1
Hi,
I am a new user of Piwigo and I want to make a simple app with it.
the album structure is like this:
Category1
--sub-album11
--sub-album12
--sub-album13
Category2
--sub-album21
--sub-album22
--sub-album23
I want to display a list of latest sub-albums on the home page, like this:
--sub-album11
--sub-album12
--sub-album13
--sub-album21
--sub-album22
--sub-album23
(order by last updated)
but when I use pwg.categories.getList, it gets parent categories only.
Is there a way to display sub-albums instead?
Thank you!
Piwigo version: 2.8.5
PHP version: 5.5.9
MySQL version: 5.5.50
Offline
yes, you can with recursive and tree output to true
http://demo.piwigo.com/ws.php?format=re … utput=true
and then you extract only "sub_categories"
a little example:
<?php $objXml = new SimpleXmlElement(file_get_contents('http://demo.piwigo.com/ws.php?format=rest&method=pwg.categories.getList&recursive=true&tree_output=true')); foreach($objXml->item as $value) { //loop the response if ($value->sub_categories) { //if item has subcategories foreach ($value->sub_categories->category as $value) { //loop the subcategories echo strval($value->name) . '<br>' . PHP_EOL; //show the subcategory names } } } ?>
Last edited by eliz82 (2017-01-08 10:49:22)
Offline
Cool!
Done
Thank you very much!
eliz82 wrote:
yes, you can with recursive and tree output to true
http://demo.piwigo.com/ws.php?format=re … utput=true
and then you extract only "sub_categories"
a little example:Code:
<?php $objXml = new SimpleXmlElement(file_get_contents('http://demo.piwigo.com/ws.php?format=rest&method=pwg.categories.getList&recursive=true&tree_output=true')); foreach($objXml->item as $value) { //loop the response if ($value->sub_categories) { //if item has subcategories foreach ($value->sub_categories->category as $value) { //loop the subcategories echo strval($value->name) . '<br>' . PHP_EOL; //show the subcategory names } } } ?>
Offline
Walton wrote:
order by last updated
i didn't saw this first time when i read. yes you can also order by last updated but is a little more complicated.
PLG already made something similar
http://piwigo.org/forum/viewtopic.php?p … 34#p158834
as you can see he put the result in an array with also the date, then he sort the array.
@edit
you can put the date as key of the array value then you can can use ksort http://php.net/manual/ro/function.ksort.php , i find it more simple
Last edited by eliz82 (2017-01-08 12:26:23)
Offline
eliz82 wrote:
Walton wrote:
order by last updated
i didn't saw this first time when i read. yes you can also order by last updated but is a little more complicated.
PLG already made something similar
http://piwigo.org/forum/viewtopic.php?p … 34#p158834
as you can see he put the result in an array with also the date, then he sort the array.
@edit
you can put the date as key of the array value then you can can use ksort http://php.net/manual/ro/function.ksort.php , i find it more simple
Great, that's what I need too.
Thank you!
Offline
Pages: 1