We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    you can try this:

    in the directory: components/dynamicdropdown/processors/mgr/gallery_albums/

    put this two files:

    getoptions.albums.php

    <?php
    /**
     * DynamicDropdownTV
     *
     * Copyright 2012-2013 by Bruno Perner <[email protected]>
     *
     * DynamicDropdownTV is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the Free
     * Software Foundation; either version 2 of the License, or (at your option) any
     * later version.
     *
     * DynamicDropdownTV is distributed in the hope that it will be useful, but
     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
     * details.
     *
     * You should have received a copy of the GNU General Public License along with
     * DynamicDropdownTV; if not, write to the Free Software Foundation, Inc., 59
     * Temple Place, Suite 330, Boston, MA 02111-1307 USA
     *
     * @package dynamicdropdowntv
     * @subpackage processor
     *
     * DynamicDropdownTV example gallery albums processor for albums0 tv
     */
    $query = $modx->getOption('query', $scriptProperties, '');
    
    $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
    $inputProperties = $tv->get('input_properties');
    
    $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
    $lang = $modx->lexicon->fetch('dynamicdropdowntv.', TRUE);
    
    $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], TRUE);
    
    $packageName = 'gallery';
    $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
    $modelpath = $packagepath . 'model/';
    $modx->addPackage($packageName, $modelpath);
    
    $classname = 'galAlbum';
    $c = $modx->newQuery($classname);
    
    $options = array();
    $count = 1;
    
    if (!empty($query)) {
    	$c->where(array('name:LIKE' => $query . '%'));
    } else {
    	$options[] = array('id' => '', 'name' => $firstText);
    }
    
    //$c->where(array('parent' => '0'));
    
    //$c->prepare();echo $c->toSql();
    if ($collection = $modx->getCollection($classname, $c)) {
    	$count += $modx->getCount($classname);
    	foreach ($collection as $object) {
    		$option['id'] = $object->get('id');
    		$option['name'] = $object->get('name');
    		$rows[strtolower($option['name'])] = $option;
    	}
    	ksort($rows);
    
    	foreach ($rows as $option) {
    		$options[] = $option;
    	}
    }
    
    return $this->outputArray($options, $count);
    
    


    getoptions.albumimages.php

    <?php
    
    /**
     * DynamicDropdownTV
     *
     * Copyright 2012-2013 by Bruno Perner <[email protected]>
     *
     * DynamicDropdownTV is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the Free
     * Software Foundation; either version 2 of the License, or (at your option) any
     * later version.
     *
     * DynamicDropdownTV is distributed in the hope that it will be useful, but
     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
     * details.
     *
     * You should have received a copy of the GNU General Public License along with
     * DynamicDropdownTV; if not, write to the Free Software Foundation, Inc., 59
     * Temple Place, Suite 330, Boston, MA 02111-1307 USA
     *
     * @package dynamicdropdowntv
     * @subpackage processor
     *
     * DynamicDropdownTV example gallery albums processor for albums1 tv
     */
    $album = $modx->getOption('albums', $scriptProperties, '');
    $query = $modx->getOption('query', $scriptProperties, '');
    
    $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
    $inputProperties = $tv->get('input_properties');
    
    $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
    $lang = $modx->lexicon->fetch('dynamicdropdowntv.', true);
    
    $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], true);
    
    $modx->resource = $modx->newObject('modResource');//we $modx->resource to get phpthumbof working
    
    $options = array();
    $count = 1;
    
    //$c->where(array('parent' => $parent));
    
    //$c->prepare();echo $c->toSql();
    $output = $firstText . '==';
    $output .= $modx->runSnippet('Gallery', array('album' => $album, 'thumbTpl' => 'TVGalThumb'));
    
    $images = explode('||', $output);
    $rows = array();
    foreach ($images as $image) {
        $parts = explode('==', $image);
        $option['id'] = $parts[1];
        $option['name'] = $parts[0];
        $rows[strtolower($option['id'])] = $option;
    }
    ksort($rows);
    
    foreach ($rows as $option) {
        $options[] = $option;
    }
    
    return $this->outputArray($options, $count);
    
    


    name your TVs albums and albumimages

    select albums as parent for albumimages

    this was working for me



      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
    • discuss.answer
      • 30912
      • 463 Posts
      Bruno, You sir are a Genius.

      For reference for anyone else that comes accross this and needs the same facility.

      Download Dynamic Dropdown TV from the repo

      Create two TV's
      1) call one albums
      2) call one albumimages

      albums TV as the folllowing:

      Input Type: Dynamic DD
      Parent: None
      Drop Down Group: gallery_albums

      albumimages TV

      Input Type: Dynamic DD
      Parent: albums
      Drop Down Group: gallery_albums

      dont forget if you are using these in MIGxdb to not assign them to a template - I havent tested a MIGx only setup.

      Create two files:

      getoptions.albums.php

      <?php
      /**
       * DynamicDropdownTV
       *
       * Copyright 2012-2013 by Bruno Perner <[email protected]>
       *
       * DynamicDropdownTV is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License as published by the Free
       * Software Foundation; either version 2 of the License, or (at your option) any
       * later version.
       *
       * DynamicDropdownTV is distributed in the hope that it will be useful, but
       * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
       * details.
       *
       * You should have received a copy of the GNU General Public License along with
       * DynamicDropdownTV; if not, write to the Free Software Foundation, Inc., 59
       * Temple Place, Suite 330, Boston, MA 02111-1307 USA
       *
       * @package dynamicdropdowntv
       * @subpackage processor
       *
       * DynamicDropdownTV example gallery albums processor for albums0 tv
       */
      $query = $modx->getOption('query', $scriptProperties, '');
       
      $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
      $inputProperties = $tv->get('input_properties');
       
      $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
      $lang = $modx->lexicon->fetch('dynamicdropdowntv.', TRUE);
       
      $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], TRUE);
       
      $packageName = 'gallery';
      $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
      $modelpath = $packagepath . 'model/';
      $modx->addPackage($packageName, $modelpath);
       
      $classname = 'galAlbum';
      $c = $modx->newQuery($classname);
       
      $options = array();
      $count = 1;
       
      if (!empty($query)) {
          $c->where(array('name:LIKE' => $query . '%'));
      } else {
          $options[] = array('id' => '', 'name' => $firstText);
      }
       
      //$c->where(array('parent' => '0'));
       
      //$c->prepare();echo $c->toSql();
      if ($collection = $modx->getCollection($classname, $c)) {
          $count += $modx->getCount($classname);
          foreach ($collection as $object) {
              $option['id'] = $object->get('id');
              $option['name'] = $object->get('name');
              $rows[strtolower($option['name'])] = $option;
          }
          ksort($rows);
       
          foreach ($rows as $option) {
              $options[] = $option;
          }
      }
       
      return $this->outputArray($options, $count);


      getoptions.albumimages.php

       
      <?php
       
      /**
       * DynamicDropdownTV
       *
       * Copyright 2012-2013 by Bruno Perner <[email protected]>
       *
       * DynamicDropdownTV is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License as published by the Free
       * Software Foundation; either version 2 of the License, or (at your option) any
       * later version.
       *
       * DynamicDropdownTV is distributed in the hope that it will be useful, but
       * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
       * details.
       *
       * You should have received a copy of the GNU General Public License along with
       * DynamicDropdownTV; if not, write to the Free Software Foundation, Inc., 59
       * Temple Place, Suite 330, Boston, MA 02111-1307 USA
       *
       * @package dynamicdropdowntv
       * @subpackage processor
       *
       * DynamicDropdownTV example gallery albums processor for albums1 tv
       */
      $album = $modx->getOption('albums', $scriptProperties, '');
      $query = $modx->getOption('query', $scriptProperties, '');
       
      $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
      $inputProperties = $tv->get('input_properties');
       
      $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
      $lang = $modx->lexicon->fetch('dynamicdropdowntv.', true);
       
      $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], true);
       
      $modx->resource = $modx->newObject('modResource');//we $modx->resource to get phpthumbof working
       
      $options = array();
      $count = 1;
       
      //$c->where(array('parent' => $parent));
       
      //$c->prepare();echo $c->toSql();
      $output = $firstText . '==';
      $output .= $modx->runSnippet('Gallery', array('album' => $album, 'thumbTpl' => 'TVGalThumb'));
       
      $images = explode('||', $output);
      $rows = array();
      foreach ($images as $image) {
          $parts = explode('==', $image);
          $option['id'] = $parts[1];
          $option['name'] = $parts[0];
          $rows[strtolower($option['id'])] = $option;
      }
      ksort($rows);
       
      foreach ($rows as $option) {
          $options[] = $option;
      }
       
      return $this->outputArray($options, $count);
      


      Upload the two files to the directory:

      components/dynamicdropdown/processors/mgr/gallery_albums/

      Create a Chunk TVGalThumb

      Now, if you want to use this in a template use this code:

      ||<img src="[[+image_absolute:phpthumbof=`&w=100&h=100`]]">==[[+image_absolute]]


      if you are using it within MIGxdb use this code

      ||<img src="[[+image_absolute:phpthumbof=`&w=100&h=100`]]">==[[+id]]





      [ed. note: Tyreal2012 last edited this post 10 years, 5 months ago.]