Loading...
 

Documentation


How do you embed a Mathematica CDF in a Tikiwiki blog post?

posts: 13 United States

I'm trying to post a Mathematica CDF to my Tikiwiki 12 blog but can't get it to work quite right. I created a CDF to demonstrate the Fermi-Dirac function. The fermidistribution.cdf file was uploaded to the file gallery with fileID=55. The femidistibustion.png was uploaded to the file gallery with fileID=56. The files can be retrieved in several ways as far as I can tell. The dlxx means download the file with fileID=xx. The displayxx means display file with fileID=xx. The files are loaded into the MySQL database instead of being stored in a directory.

I tried the two syntax options based on what the “From Desktop to Web: Deploying Ideas with CDF” video indicated. The first option uses the download syntax and the second option uses the display option. I call the html file using the Tikiwiki {IFRAME()} command in the blog posting. The {IFRAME()} command was used in the following forms and the resulting actions are indicated as well:

1. {IFRAME(width="596" height="614" scrolling="no" src=https://www.p-brane.com/nano/display64)}{IFRAME} ⇒Yields a blank frame
2. {IFRAME(height=596,width=614, scrolling=auto)}tiki-print.php?field=64{IFRAME} ⇒ Yields the home page with an error message
3. {IFRAME(width="596" height="614" scrolling="no")}tiki-download_file.php?fileID=63{IFRAME} ⇒ Yields a download box. If you open the file in the browser then the cdf plays and functions as expected.
4. {IFRAMEx(width="596" height="614" scrolling="no" src=https://www.p-brane.com/nano/dl64)}{IFRAME} ⇒ Yields a download box (same as 3). If you open the file in the browser then the cdf plays and functions as expected.

What is the proper syntax to use so that the cdf runs without having to open a file to an new browser window or tab (using IFRAME or something else)? I could not get my html code to display correctly so to keep the script command form being delete I called it xscript.


Option one has fileID=64

sample1 iframe command
<html>	
<body>

<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
<script type="text/javascript">
var cdf = new cdfplugin();
cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="https://www.p-brane.com/nano/dl56"></a>');
cdf.embed('https://www.p-brane.com/nano/dl55', 596, 614);
</script>

</body>
</html>


Option two has fileID=63

sample2 iframe command
<html>
<body>

<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
<script type="text/javascript">
var cdf = new cdfplugin();
cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="https://www.p-brane.com/nano/display56"></a>');
cdf.embed('https://www.p-brane.com/nano/display55', 596, 614);
</script>

</body>
</html>


Update 2/23/14
Mathematica technical support provided this sample HTML code for embedding a CDF into a web page. This code, however, does not produce a working CDF in a Tiki Blog.

sample3 iframe command
<!DOCTYPE html>
<html>
<p>This is a template for CDF examples</p>
<body>

    <script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
    <script type="text/javascript">
        var cdf = new cdfplugin();
        cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="Case628259-FermiDistribution.png"></a>');
        cdf.embed('Case628259-FermiDistribution.cdf', 710, 710);
        </script>

</body>
</html>


I also tried this with a HTML iframe but it did not work either. The Tikiwiki editor also likes to throw in some in the script and iframe commands.

sample4 iframe command
{HTML(wiki="0")}<!DOCTYPE html>
<html>
<p>This is a template for CDF examples</p>
<iframe width="596" height="614">
<body>

    <script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
    <script type="text/javascript">
        var cdf = new cdfplugin();
        cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="https://www.p-brane.com/nano/dl56"></a>');
        cdf.embed('https://www.p-brane.com/nano/dl55', 710, 710);
        </script>

</body>
</iframe>
</html>{HTML}


Update 2/24/14
I discovered that the following code works in IE but not in Firefox or Chrome:

This code runs fine in IE.

{IFRAME(width="710" height="710" scrolling="no" src=https://www.p-brane.com/nano/display63)}
{IFRAME}


where display63 contains

sample5 HTML code called by the iframe command
<html>
<body>

<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
<script type="text/javascript">
var cdf = new cdfplugin();
cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="https://www.p-brane.com/nano/display56"></a>');
cdf.embed('https://www.p-brane.com/nano/display55', 596, 614);
</script>

</body>
</html>
posts: 13 United States
It seems the
~pp~ 
~/pp~ doesn't completely convert html code to text and this editor deletes some of it. Sorry I can't figure out how to make it display properly.

posts: 13 United States
I used the {CODE()} command this time and it now displays the HTML sections properly.

posts: 3558

I'm not familar with Mathematica or a CDF file, but here goes...

What exactly are you trying to embed?

The https://www.p-brane.com/nano/display56 that you reference is simply a PNG file, which (I don't think) is valid inside an IFRAME element.

The https://www.p-brane.com/nano/display63 appears to be an HTML file, right, that you're storing in the file gallery?

Where is the acutal CDF file? Is it https://www.p-brane.com/nano/dl55

Have you tried to use the HTML plugin instead of IFRAME? Or even the JS plubin should work:

{js file="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"}
{JS()}    var cdf = new cdfplugin();
    cdf.embed('https://www.p-brane.com/nano/dl55', 588, 380);
{JS}




HTH,

- Rick | My Tiki Blog | My Tiki UserPage

Why be a dummy? Get smarty! TikiForSmarties.com
Tiki for Smarties, your source for the best (and only) Tiki books, guides, and tutorials.
posts: 13 United States

Hi Rick,
Yes https://www.p-brane.com/nano/display56 is the fermidistribution.png file, and the https://www.p-brane.com/nano/display63 is the html code shown in the sample2 iframe command above. The fermidistribution.cdf file is stored in as https://www.p-brane.com/nano/dl55 or as https://www.p-brane.com/nano/display55 depending if you are downloading or displaying it (respectively). I tried the html command as shown in sample3 and sample4 above. It did not produce anything (blank frame).

I have not tried the js plugin and will give it a try. Thank you.

I did get it to work in IE only using the iframe command and the html shown in sample5. The CDF hops around in the frame for some reason. For some reason, this does not work in Firefox or Chrome.

posts: 13 United States

Hi Rick,
The JS did not work in Firefox or Chrome either. It works in IE 8 and so does the IFRAME example. Mathematica support says it works in Safari but not Fireforx or Chrome. It's still not clear where the problems is.


Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.