Search code examples
phpmodxmodx-revolution

Modx Revolution SlideshowManager - list all albums


I am trying to list all albums that are available in the SlideshowManager Addon in a TV List.

To do so I am trying to make a snippet for that like it is described here https://github.com/jgulledge19/Slideshowmanager/blob/master/core/components/slideshowmanager/processors/mgr/album/getlist.php

But I don't get any results. Here is what I have so far.

The TV

@eval return $modx->runSnippet('jgSlideshowAlbum__getList',array());

My Snippet

<?php
// create query
$query = $modx->newQuery('jgSlideshowAlbum');
// $query->limit(10);
$query->where(array('title:=' => 'Main Slideshow'));
// get albums
$albums = $modx->getIterator('jgSlideshowAlbum',$query);
// return result as list
foreach($albums as $album) {
die(print_r($album->toArray()));
}

For the moment I just want some output so I die() if there was found something.

EDIT/UPDATE

Here the output of the Errorlog

[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class 
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class !
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class jgSlideshowAlbum
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:53:28] (ERROR @ /manager/index.php) ::getSelectColumns() is not a valid static method.
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class 
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class !
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class jgSlideshowAlbum
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) No class specified for loadClass
[2014-03-18 11:54:35] (ERROR @ /manager/index.php) ::getSelectColumns() is not a valid static method.
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:54] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class 
[2014-03-18 11:54:54] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class !
[2014-03-18 11:54:54] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:54:54] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class jgSlideshowAlbum
[2014-03-18 11:54:54] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:54:54] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:54:54] (ERROR @ /index.php) ::getSelectColumns() is not a valid static method.
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:56:11] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class 
[2014-03-18 11:56:11] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class !
[2014-03-18 11:56:11] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:56:11] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class jgSlideshowAlbum
[2014-03-18 11:56:11] (ERROR @ /index.php) Could not load class: jgSlideshowAlbum from mysql.jgslideshowalbum.
[2014-03-18 11:56:11] (ERROR @ /index.php) No class specified for loadClass
[2014-03-18 11:56:11] (ERROR @ /index.php) ::getSelectColumns() is not a valid static method.

Solution

  • How about to call the original processor in your snippet?

    <?php
    
    $limit = 0;
    $sort = 'id';
    $dir = 'ASC';
    $query = '';
    
    $properties = array(
        "limit" => $limit,
        "sort" => $sort,
        "dir" => $dir,
        "query" => $query
    );
    
    $slideshowmanagerPath = $modx->getOption('slideshowmanager.core_path',null,$modx->getOption('core_path').'components/slideshowmanager/');
    
    $modx->addPackage('slideshowmanager',$slideshowmanagerPath.'model/');
    
    $otherProps = array(
        'processors_path' => $slideshowmanagerPath . 'processors/'
    );
    
    $response = $modx->runProcessor('mgr/album/getlist', $properties, $otherProps);
    $albums = $modx->fromJSON($response->response);
    
    $output = '';
    foreach($albums['results'] as $album) {
        if (!empty($output)) $output .= '||';
        $output .= $album['title'] .'=='.$album['id'];
    }
    
    return $output;