We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 727
    • 502 Posts
    Quote from: ZAP at May 07, 2006, 12:38 PM

    Quote from: ajayre at May 07, 2006, 12:01 PM

    I added spaces before and after the ampersands - didn’t help. I have the page published, but I don’t have any photos added because I can’t run the snippet.
    Hmm... I know you said you cut and pasted the snippet twice already, but that just sounds like an error in the snippet code to me. Maybe a third time?

    That PHP error seems like you are missing a ; or a } in the line(s) immediately above where the error shows up. I’ve had it when I’ve commented out parts of a script and then realized that I’d put /* at the end as well as at the beginning. Did you make any changes to the snippet at all?

    And just to confirm: You are running the latest MODx, right?

    Thanks to debugging steps from Doze I found the problem and solution.
    Pasting the snippet code appeared to be ok, however it was actually truncating it when I clicked on Save. Viewing the code again showed it to be truncated.
    This happens in IE 6 and FF 1.5, so might be a PHP or MODx problem.
    The only solution I could find was to paste the snippet code using phpMyAdmin.

    I am using MODx 0.9.2.1 and PHP 4.4.0

    Thanks for the help!

    Andy
      • 33372
      • 1,611 Posts
      That’s weird. I use exactly the same version of MODx and PHP on the same two browsers and I’ve never had that happen. What you describe does sound like like some sort of weird form posting error in MODx.

      Anyway the important thing is that you figured it out and got it working.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 33372
        • 1,611 Posts
        Just in case anyone else finds it useful, I’m posting the snippet that I’m using to script lightbox galleries into a slideshow that opens when you load the page. It’s just a hacked version of MaxiGallerySolo, but I’ve removed the non-lightbox code and added the id tags that the JavaScript needs to launch it automatically. I have also removed the image display code in favor of a text link to launch the slideshow manually (but this is easy to change to something else if you prefer).

        You need to modify the end of the lightbox.js script to make this work (see my previous post in this thread for details). And of course you need to do everything else necessary to make MaxiGallery and MaxiGallerySolo work. Which is just to say that if MaxiGallery doesn’t work then of course this won’t either.

        I have also commented out the code that automatically add the lightbox head code to documents with this snippet because there is still an unresolved intermittant bug in MODx that causes it to sometimes not add it. For now I recommend that you create a template for these pages and add that code to the head of that template manually. See the comments in the snippet itself for the code to cut and paste.

        ////////////////////////////////////////////////////////////////////////////////////////////
        // MaxiGalleryTour - a scripted version of
        // MaxiGallerySolo by XriS (modified by doze)
        // hacked together by ZAP
        // ------------------------------------------
        //
        // This snippet gets the latest or random pictures from a group of galleries
        // and displays them as a slideshow automatically when the page loads.
        //
        // This ONLY works with the Lightshow v2 display method and only after modifying lightshow.js to auto-launch
        //
        // Example call: [!MaxiGalleryTour? &galIDs=`9,10,11,12,13,14,15` &link_text=`Click here to launch slideshow` &type=`random`!]
        //
        // Parameters:
        // &galIDs			= Comma delimitted IDs of documents with [MaxiGallery] snippets and associated galleries
        // &link_text		= Text in order to lauch the slideshow manually (leave blank for no manual launch link)
        // &type		    	= [ "random" | "latest" ] : Show random pics or latest pics? Defaults to "random"
        //
        // Or you can set the parameters here in the snippet if you don't need to vary them, like so:
        
        $galIDs = '9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40'; //set all gallery IDs here
        $link_text = 'Click here to launch slideshow';
        
        function regClientScripts(){
        	global $modx;
        	//lightbox scripts
        	$lightboxv2_css_link = '<link rel="stylesheet" href="' . $modx->config['site_url'] . 'assets/snippets/maxigallery/lightboxv2/css/lightbox.css" type="text/css" media="screen" />';
        	$lightboxv2_script_link1 = $modx->config['site_url'] . 'assets/snippets/maxigallery/lightboxv2/js/prototype.js';
        	$lightboxv2_script_link2 = $modx->config['site_url'] . 'assets/snippets/maxigallery/lightboxv2/js/scriptaculous.js?load=effects';
        	$lightboxv2_script_link3 = $modx->config['site_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox.js';
        
        	$modx->regClientCSS($lightboxv2_css_link);
        	$modx->regClientStartupScript($lightboxv2_script_link1);
        	$modx->regClientStartupScript($lightboxv2_script_link2);
        	$modx->regClientStartupScript($lightboxv2_script_link3);
        }
        
        $output='';
        if(isset($galIDs)){
        	$type = isset($type) ? $type : "random";
        	$galIDs = str_replace(",", "','", $galIDs);
        	$pics=$modx->getIntTableRows("*","maxigallery", "gal_id IN ('" . $galIDs . "')","pos,title","ASC");
        	$i=0;
        	if($type == "random") shuffle($pics);
        	for($i = 0; $i < count($pics); $i++) {
        		$pic = $pics[$i];
        		$path_to_gal = 'assets/galleries/'.$pic['gal_id'].'/';
        		$file = $modx->config['site_url'] . $path_to_gal . $pic['filename'];
        $output .= "\n".'<a id="img'.$i.'" href="'.$file.'" rel="lightbox[maxigallery]" title="'.htmlentities(stripslashes($pic['title'])).' - '.htmlentities(stripslashes($pic['descr'])).'">';
        		$output .= ($i == 0 ? $link_text : '').'</a>';
        	}
           // I have commented the line below until the function works reliably:
           // regClientScripts();
           // It should add the lightbox JS and CSS to the document head
           // but a bug in the document parser is causing it to sometimes not add this code
           // For now I have just added the lightbox JS and CSS code to the head of a template file
           // Later when this bug has been addressed you can use this function instead if you like
           // The lines to add to your head in the meantime are:
           /*
           <link rel="stylesheet" href="http://www.yourdomainname.com/assets/snippets/maxigallery/lightboxv2/css/lightbox.css" type="text/css" media="screen" />
           <script type='text/javascript' language='JavaScript' src='http://www.yourdomainname.com/assets/snippets/maxigallery/lightboxv2/js/prototype.js'></script>
           <script type='text/javascript' language='JavaScript' src='http://www.yourdomainname.com/assets/snippets/maxigallery/lightboxv2/js/scriptaculous.js?load=effects'></script>
           <script type='text/javascript' language='JavaScript' src='http://www.yourdomainname.com/assets/snippets/maxigallery/lightboxv2/js/lightbox.js'></script>
           */
        }
        return $output;

        The next step is to change the Lightbox JavaScript to optionally step through the slides automatically after X seconds instead of having to click "Next"...
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 727
          • 502 Posts
          Quote from: ZAP at May 07, 2006, 04:25 PM

          That’s weird. I use exactly the same version of MODx and PHP on the same two browsers and I’ve never had that happen. What you describe does sound like like some sort of weird form posting error in MODx.

          Anyway the important thing is that you figured it out and got it working.

          Maybe it would be possible to move the bulk of the snippet code into a PHP file inside the assets/snippets/maxigallery folder and include() it in the snippet?

          Andy
            • 24166
            • 11 Posts
            Quote from: doze at May 07, 2006, 04:02 PM

            That class in watermark folder is used to create all thumbnails, with or without watermarks. It seems that you don’t have GD library installed on your webserver or the GD library is too old. It has to be versio 1.8 or later.

            You can check what version you have by looking at the phpinfo() at modx manager. Go to administration > view system info and click view at the phpinfo block.

            [table][tr][td]GD Support[/td][td]enabled[/td][/tr]

            [tr][td]GD Version[/td] [td]bundled (2.0.28 compatible)[/td][/tr]
            [tr][td]FreeType Support[/td] [td]enabled[/td][/tr]
            [tr][td]FreeType Linkage[/td] [td]with freetype[/td][/tr]
            [tr][td]GIF Read Support[/td] [td]enabled[/td][/tr]
            [tr][td]GIF Create Support[/td] [td]enabled[/td][/tr]
            [tr][td]JPG Support[/td] [td]enabled[/td][/tr]
            [tr][td]PNG Support [/td][td]enabled[/td][/tr]
            [tr][td]WBMP Support[/td] [td]enabled[/td][/tr]
            [tr][td]XBM Support[/td] [td]enabled[/td][/tr][/table]
              • 7923
              • 4,213 Posts
              Quote from: ajayre at May 07, 2006, 04:13 PM

              Thanks to debugging steps from Doze I found the problem and solution.
              Pasting the snippet code appeared to be ok, however it was actually truncating it when I clicked on Save. Viewing the code again showed it to be truncated.
              This happens in IE 6 and FF 1.5, so might be a PHP or MODx problem.
              The only solution I could find was to paste the snippet code using phpMyAdmin.
              Quote from: ZAP at May 07, 2006, 04:25 PM

              That’s weird. I use exactly the same version of MODx and PHP on the same two browsers and I’ve never had that happen. What you describe does sound like like some sort of weird form posting error in MODx.

              When I checked the code to see what line the eval error was pointing to, I found out that it was the line what has international characters and maybe on some server setups, they will cause errors when posting the snippet to the database.. The line is:
              $filename = strtr($filename, "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöùúûüýþÿ ", "aaaaaaaceeeeiiiidnooooo0uuuuypsaaaaaaaceeeeiiiionooooouuuuypy_");

              And the purpose of that line is to salvage any illegal characters from the filename before I use regexp to strip them out.

              Maybe in the next version it would be good to put the snippet logic code to a external file and include it at the snippet code like Andy said.. The functions will be in a separate file at the next version anyway..

              Quote from: qnick at May 08, 2006, 03:49 AM

              GD Support enabled
              GD Version bundled (2.0.28 compatible)
              ....
              So you have GD library enabled ok.. What’s the size of the pic you are trying to upload? What type is it, gif, png, jpg? Are you trying to upload multiple pictures at the same time? Have you tried with different/smaller pics? hmm.. well, answer to those first and I’ll think of more questions to ask smiley


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 24166
                • 11 Posts
                Quote from: doze at May 08, 2006, 04:25 AM

                Quote from: qnick at May 08, 2006, 03:49 AM

                GD Support enabled
                GD Version bundled (2.0.28 compatible)
                ....
                So you have GD library enabled ok.. What’s the size of the pic you are trying to upload? What type is it, gif, png, jpg? Are you trying to upload multiple pictures at the same time? Have you tried with different/smaller pics? hmm.. well, answer to those first and I’ll think of more questions to ask smiley
                I’m trying to upload this picture.
                Yes, I have tried with smaller pic.
                  • 727
                  • 502 Posts
                  Yesterday I was able to upload pictures, etc. Today clicking on the Manage Pictures button has no effect - it just reloads the page. I’m including the snippet call in a template. Any ideas?

                  Andy
                    • 727
                    • 502 Posts
                    Duh - the snippet was being cached. That’s twice this problem has bitten me with MODx. Reminds me of when I started using PHP and I kept forgetting to use "global" again, and again...

                    Andy
                      • 7923
                      • 4,213 Posts
                      Quote from: qnick at May 08, 2006, 04:59 AM

                      Quote from: doze at May 08, 2006, 04:25 AM

                      Quote from: qnick at May 08, 2006, 03:49 AM

                      GD Support enabled
                      GD Version bundled (2.0.28 compatible)
                      ....
                      So you have GD library enabled ok.. What’s the size of the pic you are trying to upload? What type is it, gif, png, jpg? Are you trying to upload multiple pictures at the same time? Have you tried with different/smaller pics? hmm.. well, answer to those first and I’ll think of more questions to ask smiley
                      I’m trying to upload this picture.
                      Yes, I have tried with smaller pic.
                      I’m sorry, but I don’t know what’s going on.. I thought that the pics would be corrupted somehow, because that can cause errors like this.. but they uploaded fine here. Have anyone else had problems like this?


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."

                      This discussion is closed to further replies. Keep calm and carry on.