0

I have created a block to display flash content. All it needs a a variable to be assigned dynamically from the content to flashVar. I created a field called myfile path in the custom content type. Which is just a text pointing to the path of file. I also created a block and below is the code inside the block.

<?php
$myFilePath = field_get_items('node', $node, 'field_myfilepath');
?>

<script src="/player/swfobject.js"></script>
<script>
        function swfDimensions(width,height)
        {
           document.getElementById('altContent').style.width=width+'px';
           document.getElementById("altContent").style.height=height+'px';
        }
        var flashvars = {
                    filepath:"<?php echo $myFilePath;?>" // this where I use the filed value which my flash app uses internally

        };
        var params = {
            menu: "false",
            scale: "noScale",
            allowFullscreen: "true",
            allowScriptAccess: "always",
            bgcolor: "",
            wmode: "direct" // can cause issues with FP settings & webcam
        };
        var attributes = {
            id:"altContent"
        };
        swfobject.embedSWF(
            "/player/contentviewer.swf", 
            "altContent", "640px", "390px", "11.3.0",
            "/player/expressInstall.swf",
            flashvars, params, attributes);
    </script>
        <h4>Floorplan Basic</h1>

    <div id="altContent">
                To view this content you need Adobe flash player (v11+) plug-in installed on your browser
        <p><a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>
    </div>

I am getting this error

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7663 of C:\...\www\includes\common.inc).

Can any on tell me how to get the value of the field in this block? I am totally new to drupal.

1

I guess $node is not defined. You should know when a node page is shown. Then get the node id using arg(1). Load the node object and then use.

| improve this answer | |
0

Try variable_set() and variable_get()

Set the variable like that:

// I have assumed the variable name to be "the_name_of_the_variable"
variable_set("the_name_of_the_variable", "the value of the variable");

And then retrieve the value like that:

$my_variable = variable_get("the_name_of_the_variable", "a default value in case the variable has never been set before");
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.