We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20644
    • 37 Posts
    Hi vega2000 smiley
    Please show me your setting of gallery2 modules ..



    And I post new information!
    I found the way RandomImage Snipet working on gallery2 2.1.2!!
    and I add some fix to RandomImage Snipet.

    <?php
    /**
     *	ImageBlock
     *	Gallery2 Image Block for MODx
     *	
     *	Shows randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem.
     *
     *	Depend on the gallery module
     *	Version: 1.1  
     *  
     *  You have to call it uncached : [!ImageBlock!] 
     *  or for example , add option [!ImageBlock? &pageid=`5`&blocks=`recentImage`&show=`title|date|views`!]
     *  default parameter is set to $pageid="-1" , $blocks="randomImage",$show="title|date"
     *  pageid is default set to "-1". it means link to gallery2 directly. 
     * 
     *  Parameter (for the getImageBlock line 42): 
     *  'blocks': List composed with the following items : randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem ; Separate items with pipes (|) (except specificItem); default value is randomImage
     *  'show':	List composed with the following items : title, date, views, owner, heading, fullSize ; Separate items with pipes (|) ; the value can be : none (in this case you'll just have the image showing)
     * 'itemId': Limit the selection to a specific item ;
     * 'maxSize': Max siez of the image (by default it shows thumbnails)
    **/
    
    # build mod path
    $modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
    # include main class
    include_once $modpath."g2cms.base.class.inc.php";
    $gb = new G2CMS_Base();
    require_once($gb->g2Path.'embed.php'); 
    
    //Parameter
    
    //Gallery2 Embeded page id  ( snipet)
    $pageid = isset($pageid)? $pageid : '-1';  // if you want to link to gallery2 directly , must be set "-1".
    //blocks
    $blocks = isset($blocks)? $blocks : 'recentImage';
    //show
    $show = isset($show)? $show : 'title';
    //itemId
    $itemId = isset($itemId)? $itemId : null;
    
    
    
    if ( $pageid ==  "-1"){
       $uri=$gb->g2Uri;   // link to gallery2 directly
    }
    else{
       $uri=$modx->makeUrl($pageid); // link to embeded page
    }
    
    $ret = GalleryEmbed::init(array(
    	   'embedUri' => $uri,
               'g2Uri' => $gb->g2Uri,
               'fullInit' => true
    ));
    
    if ($ret) { 
    	 echo $ret->getAsHtml();
    } 
    if($blocks =="specificItem"){
       list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show",'itemId' => "$itemId"));
    }
    else{
       list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show"));
    }
    if ($ret) { 
    	 echo $ret->getAsHtml();
    } 
    list($title, $css, $javascript) = GalleryEmbed::parseHead($headHtml); 
    $header = '';
    foreach($css as $c) $modx->regClientCSS($c);
    foreach($javascript as $j) $modx->regClientStartupScript($j);
    /* Shows the image block. */
    print $bodyHtml;
    ?>

      • 20644
      • 37 Posts
      Hi everyone!!!

      I released "Gallery2 Integration 1.1.1".

      http://modxcms.com/Gallery-2-Integration-1.1.1-1469.html

      <From 1.1 to 1.1.1>
      Some fix...
      1.Add fullInit to GlleryEmbed::Init() in "plugin","export.class","import.class".
      2.Back to GalleryEmbed::Init(’activeUserId’ => ) not using checkActiveUserId.
      3.Fix for redirect.
      4.Add new Snipet "ImageBlock" (Thanks nicpan!) It’s renamed and modified RandomImage snipet.
        • 27136
        • 12 Posts
        im getting the following error when i try to run the module in modx

        Warning: G2CMS_Admin::require_once() [function.G2CMS-Admin-require-once]: open_basedir restriction in effect. File(/embed.php) is not within the allowed path(s): (/home/jackal/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24
        
        Warning: G2CMS_Admin::require_once(/embed.php) [function.G2CMS-Admin-require-once]: failed to open stream: Operation not permitted in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24
        
        Fatal error: G2CMS_Admin::require_once() [function.require]: Failed opening required '/embed.php' (include_path='/home/jackal/public_html/shtuck/manager/includes/') in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24
          • 20644
          • 37 Posts
          Hi shtuck wink

          What version do you use ?
          "g2cms.admin.class.inc.php on line 24" in version 1.1 or 1.1.1 is not "embed.php"
          If you are using version 1.1 or 1.1.1 , the new version files admin.class.inc etc have not been uploaded maybe.
            • 25483
            • 741 Posts
            can this module work with gallery 2.2.1?

            I get a error that he can’t find embed.php, I did try relative and absolute paths.

              with regards,

              Ronald Lokers
              'Front-end developer' @ h2o Media

              • 31377
              • 2 Posts
              Quote from: muramoto at Apr 25, 2007, 08:31 PM

              Hi vega2000 smiley
              Please show me your setting of gallery2 modules ..
              .....

              The g2 module is config like this..

              Module configuration: &mpth=Module Path;string;assets/modules/gallery/ &g2pth=G2 path(ex /var/www/html/gallery2/;string; &g2uri=URL path to G2(ex /gallery2/);string; &g2dftgrp=Default Gallery2 group the user is added(When calling OnWebSaveUser and Exporting new users);string;Registered Users &ondel=When deleting;list;Leave Gallery user,Delete Gallery user;Delete Gallery user &admid=Admin User;string;admin

              G2 path(ex /var/www/html/gallery2/: /web_root/of/server/gallery2_map/

              URL path to G2(ex /gallery2/): /gallery2_map/

              Default Gallery2 group the user is added(When calling OnWebSaveUser and Exporting new users): Registered Users

              When deleting: Delete gallery users

              Admin User: vega2k
                • 32942
                • 141 Posts
                Your G2-Module is great nothing against it, but some general things agains G2 itself.
                As I know it is the by far slowest and most ressource wasting gallery out there.
                Even high-end server are getting into troubles if you have massive site visits.

                Why is this so?

                MODx is crying for a general management system, that you can extend by plugins to specialize in images or mp3s or whatever.

                I don’t know, but maybe Ditto can handle this. any idea?
                  • 16450
                  • 15 Posts
                  Few notes in my dealings with setting up the G2-modX integration:

                  Don’t forget to enter the configuration settings in the Gallery Module!
                  yeah, I know, seems obvious but still. duh.

                  I also edited the PHP module code for Gallery to get rid of the default screen and jump straight to the Site Admin of Gallery, once it’s all setup, no point in having the Import/Export any more.

                  Currently it only adds/edits Web Users ... would be handy for Manager Users too (which should be a quick fix, but still need to go code diving to verify).

                  Would be sweet to be able to have a snippet that can go directly to a specific album chosen as a template variable ... sooooo, I just created it, hopefully this makes sense and I have everything:

                  First, edit the ’Gallery’ snippet, add the following after the ’GalleryEmbed::init()’ call:

                  // if we have an item id, we set it
                  // either from Gallery Album drop down, or whatever else that might be passed.
                  // so if either is set, and if doesn't already have one. added by Brenton Bartel
                  if (isset($g2_itemId) && !GalleryUtilities::hasRequestVariable('itemId')) {
                          GalleryUtilities::putRequestVariable('itemId', $g2_itemId);
                  }
                  


                  Next, create a Template Variable with whatever name and description you want, and with:
                  Input Type: "DropDown List Menu"
                  Input Option Values: @EVAL include_once(’/abs_path/assets/modules/gallery/tv_albums.php’); return getAlbumsForTemplateVariable();

                  And create the tv_albums.php file with the following:

                  <?php
                  /**
                   * This is probably the ugliest work around, but this is the only way I could figure out to
                   * get it all to work.
                   * For the Template Variable, do something like this:
                   *
                   *      @EVAL include_once('/abs_path/assets/modules/gallery/tv_albums.php'); return getAlbums
                  ForTemplateVariable();
                   *
                   * Where it's all on 1 line, and the include_once is absolute path to this file.
                   */
                  
                  function getAlbumsForTemplateVariable() {
                  
                          GLOBAL $modx;
                  
                          # build mod path
                          //$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
                          $modpath = dirname(__FILE__);
                  
                          # include main class
                          include_once $modpath."/g2cms.base.class.inc.php";
                  
                          $gb = new G2CMS_Base();
                  
                          $uname = $modx->getLoginUserName();
                  
                          //require_once($gb->g2Path.'embed.php');
                          require_once('/abs_path/gallery2/embed.php');
                  
                          $ret = GalleryEmbed::init(array(
                                  'embedUri' => $gb->embedUri,
                                  'g2Uri' => $gb->g2Uri,
                                  'activeUserId' => $uname,
                          ));
                  
                          $albumIds = array();
                  
                          /* Get ids of all all albums where we can add new album items */
                          list ($ret, $albumIds) = GalleryCoreApi::fetchAllItemIds('GalleryAlbumItem');
                          if ($ret) {
                          //    return array($ret->wrap(__FILE__, __LINE__), null);
                          }
                  
                          /* Load all the album entities */
                          list ($ret, $albums) = GalleryCoreApi::loadEntitiesById($albumIds);
                          if ($ret) {
                          //    return array($ret->wrap(__FILE__, __LINE__), null);
                          }
                  
                          $albumTree = GalleryUtilities::createAlbumTree($albums);
                  
                          $ret_val = '';  
                          $comma = '';
                          
                          // have everything we need, now need to create the dropdown code.
                          foreach ($albumTree AS $album) {
                          
                                  $ret_val .= $comma .' ';
                          
                                  for ($d = 0; $d < $album['depth']; $d++) {
                                          $ret_val .= '--';
                                  }
                          
                                  if ($album['data']['title'] != '') {
                                          $ret_val .= ' '. $album['data']['title'];
                                  }
                                  else {
                                          $ret_val .= ' '. $album['data']['pathComponent'];
                                  }
                             
                                  $ret_val .= '=='. $album['data']['id'];
                          
                                  $comma = '||';
                          }
                          
                          return $ret_val;
                  }
                           
                  ?>
                  
                  



                  Obviously you’ll have to edit the ’abs_path’ items. Should ideally be in a variable, but by this point I was getting tired, so just threw in the absolute paths.

                  And finally, call the snippet properly in your template:

                  [[Gallery? &g2_itemId=`[*TV_Name*]`]]
                  



                  Now, once this TV is assigned to a template, you should get a drop down list of all the albums when editing the document.

                  Hopefully that’s it.


                  This is my first attempt at publishing a hack/module edit ... so hopefully it makes sense. I wasn’t originally going to release this when I first created it because I didn’t have time, but now that things have settled down, here it is. I hope it makes sense ... if not, obviously just post back to the forum.

                  Cheers.

                  PS. I should note that I got this working with Gallery 2.1.2
                    • 10266
                    • 2 Posts
                    Running:
                    ModX 0.9.6 RC3
                    Gallery2 2.1.2
                    Gallery Addon 1.1.1

                    I set all parameters, and can successfully import and export users... but when I try to use the gallery admin I get hte following errors:
                    Error (ERROR_MISSING_OBJECT) : admin GalleryUser

                    * in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 142 (GalleryCoreApi::error)
                    * in modules/core/classes/GalleryCoreApi.class at line 2424 (GalleryEntityHelper_simple::loadEntityByExternalId)
                    * in modules/core/classes/GalleryEmbed.class at line 227 (GalleryCoreApi::loadEntityByExternalId)
                    * in modules/core/classes/GalleryEmbed.class at line 131 (GalleryEmbed::checkActiveUser)
                    * in /home/voguebis/public_html/assets/modules/gallery/g2cms.admin.class.inc.php at line 33 (GalleryEmbed::init)
                    * in /home/voguebis/public_html/manager/processors/execute_module.processor.php(98) : eval()’d code at line 28 (G2CMS_Admin::execute)
                    * in /home/voguebis/public_html/manager/processors/execute_module.processor.php at line 98
                    * in /home/voguebis/public_html/manager/processors/execute_module.processor.php at line 85
                    * in /home/voguebis/public_html/manager/index.php at line 543

                    Please help!
                      • 25483
                      • 741 Posts
                      Quote from: ronaldlokers at May 13, 2007, 05:56 PM

                      can this module work with gallery 2.2.1?

                      I get a error that he can’t find embed.php, I did try relative and absolute paths.

                      I reinstalled the module and now it works great with gallery 2.2.1!!

                      You can see the example at http://mediaguy.nl/gallery.html


                      Now I have a question about the imageblock, can it output the last 3 images added to the gallery? (or with the gallery snippet?)
                      And can I get the thumbnails in another size then the original thumbnails?


                      //edit

                      I found this variable to use: maxSize, but how do I use it if I want thumbnails that are 96x96 px?
                      I already have tried these value’s but they don’t work: `90`, `90px` and `90x90`

                      //edit 2

                      It has to be `90`, the problem was that it was not implented in the code yet!

                      So I added it myself, It’s a dirty fix because it will get you a value of `150` if you don’t set maxSize.

                      <?php
                      /**
                       *	ImageBlock
                       *	Gallery2 Image Block for MODx
                       *	
                       *	Shows randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem.
                       *
                       *	Depend on the gallery module
                       *	Version: 1.1
                       *  
                       *  You have to call it uncached : [!ImageBlock!] 
                       *  or for example , add option [!ImageBlock? &pageid=`5`&blocks=`recentImage`&show=`title|date|views`!]
                       *  default parameter is set to $pageid="-1" , $blocks="randomImage",$show="title|date"
                       *  pageid is default set to "-1". it means link to gallery2 directly. 
                       * 
                       *  Parameter (for the getImageBlock line 42): 
                       *  'blocks': List composed with the following items : randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem ; Separate items with pipes (|) (except specificItem); default value is randomImage
                       *  'show':	List composed with the following items : title, date, views, owner, heading, fullSize ; Separate items with pipes (|) ; the value can be : none (in this case you'll just have the image showing)
                       * 'itemId': Limit the selection to a specific item ;
                       * 'maxSize': Max siez of the image (by default it shows thumbnails)
                      **/
                      
                      # build mod path
                      $modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
                      # include main class
                      include_once $modpath."g2cms.base.class.inc.php";
                      $gb = new G2CMS_Base();
                      require_once($gb->g2Path.'embed.php'); 
                      
                      //Parameter
                      
                      //Gallery2 Embeded page id  ( snipet)
                      $pageid = isset($pageid)? $pageid : '-1';  // if you want to link to gallery2 directly , must be set "-1".
                      //blocks
                      $blocks = isset($blocks)? $blocks : 'recentImage';
                      //show
                      $show = isset($show)? $show : 'title|date';
                      //itemId
                      $itemId = isset($itemId)? $itemId : null;
                      //maxSize
                      $maxSize = isset($maxSize)? $maxSize : 150;
                      
                      
                      
                      if ( $pageid ==  "-1"){
                         $uri=$gb->g2Uri;   // link to gallery2 directly
                      }
                      else{
                         $uri=$modx->makeUrl($pageid); // link to embeded page
                      }
                      
                      $ret = GalleryEmbed::init(array(
                      	   'embedUri' => $uri,
                                 'g2Uri' => $gb->g2Uri,
                                 'fullInit' => true,
                      ));
                      
                      if ($ret) { 
                      	 echo $ret->getAsHtml();
                      } 
                      if($blocks == "specificItem"){
                         list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show",'itemId' => "$itemId", 'maxSize' => "$maxSize"));
                      }
                      else{
                         list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show", 'maxSize' => "$maxSize"));
                      }
                      if ($ret) { 
                      	 echo $ret->getAsHtml();
                      } 
                      list($title, $css, $javascript) = GalleryEmbed::parseHead($headHtml); 
                      
                      foreach($css as $c) $modx->regClientCSS($c);
                      foreach($javascript as $j) $modx->regClientStartupScript($j);
                      $ret = GalleryEmbed::done();
                      if ($ret) { 
                      	 echo $ret->getAsHtml();
                      } 
                      $bodyHtml=str_replace('<a href',$header.'<a target="_blank" href',$bodyHtml);
                      /* Shows the image block. */
                      print $bodyHtml;
                      ?>


                      //edit 3

                      I found the code to get the last 4 updates:

                      [!ImageBlock? &pageid=`120` &maxSize=`90` &show=`none` &blocks=`recentImage|recentImage|recentImage|recentImage`!] 


                      So basicly I just had to specify the block multiple times in 1 tag, it works perfect. You can see the working example at http://www.mediaguy.nl
                        with regards,

                        Ronald Lokers
                        'Front-end developer' @ h2o Media