We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34032
    • 5 Posts
    Hi there,
    I hope somebody could help me. I need to get the name of the parent album in my album_row template.. I break my head for hours, but all i get is the parent id and the name of the target album.
    The target is to show album titles which are an merge between the parent_name and the album_name:
    "parent_name - album_name" --> "nice views - Norway"

    Thanks for your Help
    Igor

    This question has been answered by igor1509. See the first response.

    [ed. note: igor1509 last edited this post 13 years, 9 months ago.]
    • discuss.answer
      • 34032
      • 5 Posts
      Hello,
      at this moment I tried this.
      Snippet:
      <?php
      // add class to work with gallery extra
      $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
      if (!($gallery instanceof Gallery)) return '';
      
      // get id of album
      $parent = $modx->getOption('parent',$scriptProperties,0);
      if (empty($parent)) return 'no id';
      
      // make query
      $c = $modx->newQuery('galAlbum');
      $c->where(array(
          'id' => $parent,
      ));
      
      $item = $modx->getObject('galAlbum',$c);
      
      // get result
      if (!empty($item)) {
          $output = $item->get('name');
      }
      else {
          $output = 'empty';
      }
      return $output;

      in my chunk I use:
      [[!albumname? &parent=`[[+parent]]`]]



      I think it's not the fastest way to do this, but at the moment the only one I could find.
      Anyone a better idea?

      Cheers
      Igor
        • 7072 ☆ A M B ☆
        • 43 Posts
        How du you call the GalleryAlbums snippet? And how do your galAlbumRowTpl look like?

          • 34032
          • 5 Posts
          Call of GalleryAlbum snippet:
          <div id="gallery" class="gallery">
          [[!GalleryAlbums? [[!If?  &subject=`[[!*parent_gallery]]` &operator=`notempty` &then=`&parent=`[[!*parent_gallery]]` &prominentOnly=`0` &showAll=`0` ` &else=`&prominentOnly=`1` `]] &albumCoverSort=`rank` &rowTpl=`AlbumRowTpl` &thumbWidth=`200` &thumbHeight=`200` &toPlaceholder=`GalleryAlbums`]]
          
          [[!Gallery? &thumbTpl=`ItemThumb[[!get_nojs?]]` &containerTpl=`AlbumTpl[[!get_nojs?]]` &checkForRequestTagVar=`1`  &thumbWidth=`200` &thumbHeight=`200` &thumbFar=`C` &thumbZoomCrop=`0` &imageWidth=`800` &imageHeight=`800` &dir=`ASC`  &useCss=`0` &toPlaceholder=`Gallery`]]
          
             [[!If? &subject=`[[+Gallery]]` &operator=`isempty` &then=`
                      <h1>[[*longtitle]]</h1>
                      <p>[[*description]]</p>
                      [[+GalleryAlbums]]
                  
                  ` &else=`
                     
                      [[+Gallery]]
                      
                  `]]
          </div>



          galAlbumRowTpl:

          <div class="albumPreview">
              <h3>[[+parent]] - [[+name]]</h3>
              <div class="thumb">
                  <a href="[[~2]]/nojs/album/[[+name:urlencode]]/"><img src="[[+image]]" alt="[[+name]]"/></a>
              </div>
              <div class="desc">
                  [[+description]]
              </div>
          </div>