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
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>.
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.
just put the TV-placeholder anywhere into the content or to your template.
and you will see its output. What is its output, then?
http://rtfm.modx.com/display/revolution20/Tag+Syntax
Resourcefields and Template-Variables (of the current resource)
cached version:
uncached version
[[!*mytv]]
[[!*pagetitle]]
placeholders
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
also placeholders, like any other modx-tag can be called uncached.
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.]