We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39438
    • 15 Posts
    Hi
    I'm still trying to get used to how things work in Modx. Meaning: I've build one site with modx evo in 2009 and then professional circumstances forced to deal with the CMSs Wordpress and Typo3 and Flash as production tool. I always wanted to come back to modx and now finally after 4 years I'm building a new project with my favorite CMS. This time I really want to deepen my knowledge and try to approach modx on a more daring and experimental level.

    Alright, I now have a problem where I need the community's support. The HTML-<head> section of my documents is put into a chunk which I call in a template. This <head> is for very particular docs which embed Flash (SWF) applications. For this purpose I use swfobject.js in the <head>. The point here is that in the end I have 3 docs with 3 different SWF embeds whereby all 3 have the same stage size, flash player minimal requirements and so on. They are all based on the same engine only with different contents. The only thing different is the path to and file name of the SWF file. Path and file name will be made dynamic by using a placeholder in a chunk to be evaluated by a snippet. That's the plan, it doesn't work, though.

    If you spare me a bit of your time, here is the flow of events.

    -1-
    I have a chunk called 'websiteHead_mRedirect'

    [-c-o-d-e-]
    <head>
    <!-- here comes a lot of stuff (meta tags, css links, javascript links) which I think is not relevant for the problem at hand. The critical part is ... -->
    <script type="text/javascript" src="assets/js/swfobject.js"></script>
    <script type="text/javascript">
    var flashvars = {};
    var params = {};
    params.menu = "false";
    params.quality = "high";
    params.scale = "showall";
    params.bgcolor = "#FFFFFF";
    params.allowfullscreen = "true";
    params.allowscriptaccess = "sameDomain";
    var attributes = {};
    [[$swfEmbed?swfPath=`[[!set_swfPath]]`]]
    </script>
    </head>
    [-e-n-d---c-o-d-e-]

    -2-
    chunk: 'swfEmbed'

    [-c-o-d-e-]
    swfobject.embedSWF("[[!+swfPath]]", "flashbox", "720", "540", "9.0.28", false, flashvars, params, attributes);
    [-e-n-d---c-o-d-e-]

    -3-
    snippet: 'set_swfPath'

    [-c-o-d-e-]
    <?php
    $id = $modx->resource->get('id');
    switch ($id)
    {
    case 14:
    $path = "assets/flash/etest/etest.swf";
    break;
    }
    $modx->setPlaceholder('swfPath', $path);
    return $modx->getChunk('swfEmbed');
    [-e-n-d---c-o-d-e-]

    There will be finally three cases in the switch-statement but for now I need to get this one working first.

    -4-
    this results in a document to:

    [-H-T-M-L-]
    swfobject.embedSWF("", "flashbox", "720", "540", "9.0.28", false, flashvars, params, attributes);
    [-e-n-d---H-T-M-L-]

    Hence, there where I expect the placeholder 'swfPath' to be evaluated and filled in, it's just empty. I have a simular case already running successfully. Different is that this includes a javascript and it's in the <head> section. Maybe this isn't possible at all. Or I'm doing something wrong and can't see it.

    What do you think, can you help?
    cheers
      • 22427
      • 793 Posts
      At the first glance that seems more complicated than necessary.
      I would define a Template Variable swf_path, assigned to the template of the documents in question.
      Then it would be sufficient to replace the last lines of your chunk 'websiteHead_mRedirect' by the following code:
      var attributes = {};
      swfobject.embedSWF("[[!+swf_path]]", "flashbox", "720", "540", "9.0.28", false, flashvars, params, attributes);
      </script>
      </head>
      
      Editing each of the documents you set the wanted value for the TV, so for document 14 the value "assets/flash/etest/etest.swf".

      Edit:
      It should be [[!*swf_path]], I think. [ed. note: ottogal last edited this post 13 years, 4 months ago.]
        • 39438
        • 15 Posts
        Quote from: ottogal at May 27, 2013, 06:38 AM
        At the first glance that seems more complicated than necessary.
        I would define a Template Variable swf_path, assigned to the template of the documents in question.

        Thanks Ottogal, you're probably right. I admit that I use this 'overcomplicated' method to avoid a TV which I'm still a bit scared of. I'll give it a try.
          • 39438
          • 15 Posts
          I defined a TV 'swf_path' and assigned it to the template in question. And under resource id=14 using that template I can enter the path. So far, so good. But, unfortunately, the result is still:
          swfobject.embedSWF("", "flashbox", "720", "540", "9.0.28", false, flashvars, params, attributes);


          Regarding the TV: Under Input Options, what do I have to select for Input Type? I selected Text. Okay?

          And under Output Options for Output Type I've selected Text too.

          And finally. Editing the Resource under Template Variables: "assets/flash/etest/etest.swf". Do I need to write it in quotes? However - both versions, with or without quotes - no luck. [ed. note: kdmeloper last edited this post 13 years, 4 months ago.]
            • 39438
            • 15 Posts
            Just a brief note to finish this thread. I can't make the TV work as Ottogal suggested. I'm sure I made everything correctly. That the placeholder doesn't get filled must be related to the fact that it all happened in a Javascript.
            I applied another workaround which gives me the option to fill the dynamics within the content section of the resource. My next attempt to master TVs will come when dealing with things not related to SWF, Javascript and <head>.
              • 4172
              • 5,888 Posts
              That the placeholder doesn't get filled must be related to the fact that it all happened in a Javascript.

              this can't be the reason. placeholder - setting happens on server-side.
              javascript-stuff on client-site.

              Does the placeholder have the correct value? Test it outside of the javascript, if you are not sure.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 39438
                • 15 Posts
                Quote from: Bruno17 at May 27, 2013, 10:54 AM
                this can't be the reason. placeholder - setting happens on server-side.
                javascript-stuff on client-site.

                Well, probably true. I must have done something wrong. When you're not familiar with TVs then you get easily spooked when it's not working. The help in the modx documentation isn't helpful either, really. For a novice it's just confusing. Once you know, you know! I did everything as Ottogal (see above) prescribed but no good.

                Does the placeholder have the correct value? Test it outside of the javascript, if you are not sure.

                The value? Yes, correct as far as I can tell. It's a path to a file and as such correct. What I'm not sure about are the things 3 posts above (Input Type, Output Type, quotes). Though I understand what they generally mean, modx is in some places very own-minded and before you know how's working, you don't know a thing. It's try and error and I lost patience. But I'll try again.
                  • 4172
                  • 5,888 Posts
                  just put the TV-placeholder anywhere into the content or to your template.

                  [[*swf_path]]


                  and you will see its output. What is its output, then?
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 39438
                    • 15 Posts
                    Quote from: Bruno17 at May 27, 2013, 01:35 PM
                    [[*swf_path]]
                    So it is an asterisk after all. Not a + sign. I missed that bit. Is it now
                    [[*swf_path]]

                    or
                    [[!*swf_path]]
                    ? Nu, I can look it up myself, of course. But maybe you can set me straight right here. It wasn't working because I used
                    [[!+swf_path]]
                    . oops
                      • 4172
                      • 5,888 Posts
                      http://rtfm.modx.com/display/revolution20/Tag+Syntax

                      Resourcefields and Template-Variables (of the current resource)
                      cached version:
                      [[*mytv]]
                      [[*pagetitle]]


                      uncached version
                      [[!*mytv]]
                      [[!*pagetitle]]


                      placeholders
                      [[+placeholder]]

                      are setted by snippets or plugins with
                      $modx->setPlaceholder($ph,$value)
                      and inside chunks, which are used by snippets for example getResources, wayfinder, getImageList and called by
                      $modx->getChunk($chunkname,$properties)
                      (placeholders will get replaced by properties) or inside chunks, if you call them with properties
                      [[$mychunk? &foo=`bar`]]


                      also placeholders, like any other modx-tag can be called uncached.

                      [[!+placeholder]]


                      In most cases, you can use the cached version.
                      Only if you have dynamic data which is changing from request to request you would the uncached version.

                      Try allways to use the cached version. Only if you have issues with not updated dynamic datas, try the unchached version.


                      [ed. note: Bruno17 last edited this post 13 years, 4 months ago.]
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!