We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    Quote from: treigh at Feb 10, 2009, 01:47 AM

    Hi guys,

    I`m getting a blank page when I add 2 or more Youtube calls on the same page. I`ve tried tweaking the snippet as suggested by tkfm and I`m still getiing that problem. Can anyone help?

    Thanks

    the blank page is an error I think you have errors set to off in php or in htacces.
    try changin the last part of the snippet to this:
    if(!defined('getIdFromUrl')) { 
    function getIdFromUrl($url) {
    	$url_parts = parse_url($url);
    	parse_str($url_parts['query']);
    	if (isset($v)) {
    		return $v;	  
    	} else {
    		return false;	
    	}
    }
    }
    


    Dimmy
      follow me on twitter: @dimmy01
      • 27733
      • 99 Posts
      Is it me or should line 69:
      $swfobject_express_url = isset($swfobject_url)?$swfobject_url:'/assets/js/swfobject/expressInstall.swf';


      be changed to:
      $swfobject_express_url = isset($swfobject_express_url)?$swfobject_express_url:'/assets/js/swfobject/expressInstall.swf';
        ------
        Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
        • 14121
        • 6 Posts
        First of all, thanks for this great plugin! It has really been a huge help.

        I do have one question, though: The use of the & rather than & for the code generated is causing my pages not to validate:

        <object id="LPmbGzQaOCs" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="243">
                <param name="movie" value=" http://www.youtube.com/v/LPmbGzQaOCs&rel=1&autoplay=0&loop=0&disablekb=0&egm=0&border=0&hl=en" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data=" http://www.youtube.com/v/LPmbGzQaOCs&rel=1&autoplay=0&loop=0&disablekb=0&egm=0&border=0&hl=en" width="400" height="243">
                <!--<![endif]-->
                  <p>This video requires the free Flash plugin.</p>
        
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
              </object>
        


        When validated gives me a ton of error messages, with the unencoded ampersands being the primary cause. Is there a way to make the generated code come out using &amp; rather than with the & by editing the snippet?

        Thanks!
          • 18830
          • 161 Posts
          I wrote my own YouTube snippet and then I discovered this one grin

          A little suggestion for your code. You could simply calculate the height of the video

          $width = isset($width)?$width:425;
          $height = $width * 0.825;
          $height = (int)$height;
          


          YouTube videos always have the same ratio.
            • 32645
            • 377 Posts
            I’m using a template variable to store the hyperlink direct to Youtube.

            I created a PHX snippet as described in the documentation for phx:urlencode;

            <?php
            $output = urlencode($output);
            return ($output);
            ?>
            


            And on a very basic template (with no stylesheets, etc) my page I put this:

            [*video:urlencode*]
            [!YouTube? &url=`[*video:urlencode*]`!]
            


            The page never loads. If I use the ID reference call instead, it works fine.

            How do I resolve the problem so that all the user has to do is include a direct link to the URL?
              • 24731 ☆ A M B ☆
              • 211 Posts
              This is in hopes it would help someone having problems when using this snippet within a ditto call. I spent a few hours trying to get it working until I realize I was using the wrong PHX call. Also the fact that the documentation assumes that the urlencode modifier on PHx is there as default did not help.

              This is my working snippet call from a ditto template:

              [!YouTube? &url=`[+phx:input=`[[GetField? &docid=`[+id+]` &field=`yturl`]]`:uri+]` &width=`300` &height=`175`!]



              I am using GetField to get the value of the template variable where I am storing the url for the document in my ditto call, and then passing the custom modifier from:

              http://wiki.modxcms.com/index.php/PHx/CustomModifiers


              I though I would post it here for future reference or anyone who might be having issues as I was.

              Cheers.
                • 3749
                • 24,544 Posts
                Thanks for posting this. smiley
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 32645
                  • 377 Posts

                  ...How do I resolve the problem so that all the user has to do is include a direct link to the URL?

                  I resolved this problem now by creating a snippet which rips out the watch part of the youtube url.

                  // phx:get_youtube
                  <?php
                  $url = $output;
                  $parsed_url = parse_url($url);
                  parse_str($parsed_url[query], $parsed_query);
                  //print_r($parsed_query);
                  return ($parsed_query['v']);
                  ?>
                  


                  Then I call in my ditto calls

                  // Only output the Youtube clip, if the tv_youtube variable is filled.
                  //
                  [+phx:if=`[+tv_youtube:get_youtube+]`:isnot=``:then=`[[Youtube? &id=`[+tv_youtube:get_youtube+]`]]`+]
                  
                    • 29875
                    • 4 Posts
                    I had the problem that the flash-video overlayed my drop-down menu.
                    I solved the problem by modifying the snippet-code from this:
                    // HTML template, based on cross-browser recommendation from SWFobject project
                    $html = '
                    	<object id="'.$ytid.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'.$width.'" height="'.$height.'">
                            <param name="movie" value="'.$yturl.'" />
                            <!--[if !IE]>-->
                            <object type="application/x-shockwave-flash" data="'.$yturl.'" width="'.$width.'" height="'.$height.'">
                            <!--<![endif]-->
                              '.$missing.'
                            <!--[if !IE]>-->
                            </object>
                            <!--<![endif]-->
                          </object>
                    ';


                    To that:
                    // HTML template, based on cross-browser recommendation from SWFobject project
                    $html = '
                    	<object id="'.$ytid.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'.$width.'" height="'.$height.'">
                            <param name="movie" value="'.$yturl.'" />
                            <param name="wmode" value="transparent" />
                            <!--[if !IE]>-->
                            <object type="application/x-shockwave-flash" data="'.$yturl.'" width="'.$width.'" height="'.$height.'">
                            <param name="wmode" value="transparent" />
                            <!--<![endif]-->
                              '.$missing.'
                            <!--[if !IE]>-->
                            </object>
                            <!--<![endif]-->
                          </object>
                    ';
                      • 40045
                      • 534 Posts
                      Thank you so much for this hint...I’m an idiot =)...My problem was that I was using PHx in a Snippet (YouTube) which is not particularly made for phx (I always thought there is something wrong with Ditto...but I use YouTube before Ditto is hooking in...) so I would have to use the :input modifier...maaaan, this would have taken days =)...now it looks like this

                      [[YouTube? &url=`[+phx:input=`[[GetField? &docid=`[+id+]` &field=`video`]]`:rawurlencode+]` &width=`100%` &height=`350` &js=`0` &egm=`1`]]
                      


                      I already tried this some time ago...that was when I made the custom phx modifier "rawurlencode"...does say more than "uri" (for me =D)...so I let that as it was...

                      thanks again!

                      EDIT: Maybe I can contribute something more than this =)...

                      I modified the URL which is parsed in the object tag to make fullscreen video possible which isn’t if you use the embed code...

                      it is simple, just add a &fs=1 at the end of the query...

                      $yturl ='http://www.youtube.com/v/'.$ytid.$related_val.$autoplay_val.$loop_val.$disablekb_val.$egm_val.$border_val.$color1_val.$color2_val.'&hl=en&fs=1';