We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19613
    • 70 Posts
    Hi
    I have a ’flash’ snippet that works fine indiviually but i need to seperate movies on the same page.

    The snippet I am using is from http://www.naf.com.au/blog/web-development/scripts/2008/09/29/flvmp3-player-for-modx/ The snippet is nice and very easy to use.

    However, If I use the snippet call below I get two instances of whichever .FLV was called last.
    Clearly I am doing something wrong... (unless the snippet only allows one instance of flash per page, which would make it redundant in this case) :’(

    Any ideas?


    If this is not possible are there any other solutions to loading FLV into a page that don’t take years of PHP knowledge?

    <div>
    [[flv_mp3_player? &flv_mp3_file=`http://www.zeroshift.com/flash/zeroShift_Gear_Anim_07.flv` &height=`150` &width=`200` type=`flv` ]]
    <div>
    <div>
    [[flv_mp3_player? &flv_mp3_file=`http://www.zeroshift.com/flash/Cropped_Rig_Video.flv` &height=`150` &width=`200` type=`flv` ]]
    <div>


    Thanks grin
      • 16034
      • 107 Posts
      I think the reason is that the snippet uses placeholders, and they are the same in both calls. So I guess you could do two things:

      1) Prefix the placeholders with something different in each call, and create a separate template-chunk for each.
      2) Replace the placeholders in the snippet manually instead of letting MODx do it.
        MODx snippet-glossary 101:
        Ditto = Content Lister -- Wayfinder == Menu Builder -- Jot = Comment Control
        • 19613
        • 70 Posts
        Hi Kleist,
        Thanks for the response

        create a separate template-chunk for each.
        You mean i should make a seperate chunk for each .flv?
        I don’t think I can make additional chunks as the snippet calls the chunk to run the movie (that’s my undrstanding of it - but I am probably wrong as I am relativley new to Modx)

        the snippet is (from Author: Nick Fritzkowski www.naf.com.au):

        */
        
        //Set default params
        $rnflv_mp3_file = isset($flv_mp3_file) ? $flv_mp3_file : 'video_name.flv';
        $rnwidth = isset($width) ? $width : '230';
        $rnimage = isset($image) ? $image : '';
        $rnallowfullscreen = isset($allowfullscreen) ? $allowfullscreen : 'true';
        $rntype = isset($type) ? $type : 'flv';
        [b]
        $rncustom_chunk = isset($custom_chunk) ? $custom_chunk : 'flv_mp3_chunk';[/b]
        
        //set default params (styles and colors)
        $rnbackcolor = isset($backcolor) ? $backcolor : 'FFFFFF';
        $rnfrontcolor = isset($frontcolor) ? $frontcolor : '000033';
        $rnlightcolor = isset($lightcolor) ? $lightcolor : '000033';
        $rnscreencolor = isset($screencolor) ? $screencolor : '000000';
        
        //set settings defendant on type
        if($rntype == 'flv') { 
            //set flv height if nothing specified
            $rnheight = isset($height) ? $height : '200';
            $modx->setPlaceholder('displayheight', '&displayheight='.$rnheight);
        } else {
        //set 20 pixel height if nothing specified
        $rnheight = isset($height) ? $height : '20';
        }
        
        // Set placeholders
        $modx->setPlaceholder('flv_mp3_file', $rnflv_mp3_file);
        $modx->setPlaceholder('height', $rnheight);	
        $modx->setPlaceholder('width', $rnwidth);
        $modx->setPlaceholder('image', $rnimage);
        $modx->setPlaceholder('allowfullscreen', $rnallowfullscreen);
        
        // Set placeholders (style and colors)
        $modx->setPlaceholder('backcolor', $rnbackcolor);
        $modx->setPlaceholder('frontcolor', $rnfrontcolor);
        $modx->setPlaceholder('lightcolor', $rnlightcolor);
        $modx->setPlaceholder('screencolor', $rnscreencolor);
        
        // Return the chunk
        return $modx->getChunk($rncustom_chunk);
        ?>
        


        And the snippet calls this chunk:

        <embed
        	src="assets/snippets/flv_player/player.swf"
        	width="[+width+]"
        	height="[+height+]"
        	allowscriptaccess="always"
        	allowfullscreen="[+allowfullscreen+]"
        	flashvars="height=[+height+]&width=[+width+]&file=[+flv_mp3_file+]&image=[+image+]&backcolor=0x[+backcolor+]&frontcolor=0x[+frontcolor+]&lightcolor=0x[+lightcolor+]&screencolor=0x[+screencolor+][+displayheight+]"
        	/>
        


        To my understanding your other suggestion would work better in this case... how would i prefix the placeholders OR replace them manually?
        Sorry to be a noob but I recently made the jump from Joomla to Modx and the concepts are so diffferent. undecided

        thanks
          • 4041
          • 788 Posts
          Note that this is untested, but this technique works for me in similar situations. Use this in place of the current snippet code.

          <?php
          
          //Set default params
          $rnflv_mp3_file = isset($flv_mp3_file) ? $flv_mp3_file : 'video_name.flv';
          $rnwidth = isset($width) ? $width : '230';
          $rnimage = isset($image) ? $image : '';
          $rnallowfullscreen = isset($allowfullscreen) ? $allowfullscreen : 'true';
          $rntype = isset($type) ? $type : 'flv';
          $rncustom_chunk = isset($custom_chunk) ? $custom_chunk : 'flv_mp3_chunk';
          
          //set default params (styles and colors)
          $rnbackcolor = isset($backcolor) ? $backcolor : 'FFFFFF';
          $rnfrontcolor = isset($frontcolor) ? $frontcolor : '000033';
          $rnlightcolor = isset($lightcolor) ? $lightcolor : '000033';
          $rnscreencolor = isset($screencolor) ? $screencolor : '000000';
          
          //set settings defendant on type
          if($rntype == 'flv') {
              //set flv height if nothing specified
              $rnheight = isset($height) ? $height : '200';
              //$modx->setPlaceholder('displayheight', '&displayheight='.$rnheight);
          } else {
          //set 20 pixel height if nothing specified
          $rnheight = isset($height) ? $height : '20';
          }
          $output ='';
          $player_Array = array(
              'displayheight'   => '&displayheight=$rnheight',
              'flv_mp3_file'    => $rnflv_mp3_file,
              'height'          => $rnheight,
              'width'           => $rnwidth,
              'image'           => $rnimage,
              'allowfullscreen' => $rnallowfullscreen,
              'backcolor'       => $rnbackcolor,
              'frontcolor'      => $rnfrontcolor,
              'lightcolor'      => $rnlightcolor,
              'screencolor'     => $rnscreencolor
          );
          
           // output the player
          $output .= $modx->parseChunk($rncustom_chunk, $player_Array, '[+', '+]');
          
          
          // we need to unset the array to allow multiple snippet usage on the same page
          unset($player_Array);
          unset($rntype);
          unset($rncustom_chunk);
          
          return $output;
          ?>


          Hope it helps smiley
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 16034
            • 107 Posts
            Both my suggestions involve modifying the original snippet-code, I don’t think you can solve your problem without doing so.
            (And since this is the "Module, Plugin & Snippet Creation and Modification"-board, that’s what I thought you were looking for.)

            My second suggestion is pretty much what Breezer’s snippet code does, and that’s probably the prettier solution of the two.
              MODx snippet-glossary 101:
              Ditto = Content Lister -- Wayfinder == Menu Builder -- Jot = Comment Control
              • 10449
              • 956 Posts
              What’s the live URL of your test page?

              I’m too lazy to install the same snippet, but the resulting output is quite surprising: why use only the embed tags for Flash content? These days you should use either SWFObject or Adobe’s own JS functions to display SWF content in an HTML page.

              With SWFObject, you’ll have to remember that every wrapper DIV needs its own, unique identifier - you can’t use <div id="myFlash">...</div> twice on the same page. Only one of those DIVs will be rendered correctly.

              Without seeing your actual HTML/JS output, it’s difficult to find and correct possible bugs though...
                • 19613
                • 70 Posts
                Hi Guys,
                Sorry for the delayed response... had to take the rest of the day off.

                The url of my test page is: http://www.zeroshift.com/CMS/index.php?id=48

                I have not tested any of the last points yet but will get too it and respond.

                Why use only the embed tags for Flash content? These days you should use either SWFObject or Adobe’s own JS functions to display SWF content in an HTML page.

                I don’t know much about embedding ’flash objects’ as I never usually use flash but in this case small movies are required for the site. I found the snippet mentioned above and it seemed to sort my problem. If there is an ’easier’ way to get multiple flash movies (.FLV) working in a page I would be happy to use it.

                I moved over from Joomla a while ago and find modx is much cleaner code and I like the general workflow... but it feels a bit less plug and play in my experience so far (and I am not saying that is a bad thing - i can see the benefits) however the learning curve is very ’coder oriented’ in my view grin and once i have got a much firmer grip on things I am thinking or creating/contributing too a more ’designer friendly’ resource.

                I will try the snippet above and report back.
                Thanks. smiley
                  • 19613
                  • 70 Posts
                  Hi,
                  Thanks for the replacement snippet Breezer... unfortunately it produced this:
                  Parse error: syntax error, unexpected '*' in /data/zeroshift.com/CMS/manager/includes/document.parser.class.inc.php(769) : eval()'d code on line 2


                  I have temporarily put the old snippet back in.

                  Any ideas?
                    • 4041
                    • 788 Posts
                    The issue was in the first comment line */ (which I have removed both from the snippet above), maybe give it a shot again and see what happens...
                      xforum
                      http://frsbuilders.net (under construction) forum for evolution
                      • 19613
                      • 70 Posts
                      Thanks Breezer,

                      That’s working great... thanks for saving me even more hours of hair-pulling.

                      I really appreciate the effort/help/time etc
                      smiley