Integration of Shiny into a wordpress site feasable?

5,406 views
Skip to first unread message

Owe Jessen

unread,
Dec 30, 2013, 1:54:31 PM12/30/13
to shiny-...@googlegroups.com
If I remember the numbers correctly, about 1/3 of the web's sites are hosted with the help of wordpress. Insofar I'm curious if it would be feasable to integrate a shiny app - perhaps even as a wordpress plugin - into such an existing site. I think this could be a great way to leverage the strengths of both worlds tremendously.

Stéphane Laurent

unread,
Dec 30, 2013, 2:28:07 PM12/30/13
to shiny-...@googlegroups.com
If your Shiny app is hosted on a web server, you can embed it using <iframe></iframe>; see an example here http://stla.github.io/stlapblog/posts/rsm3Dshiny.html

Le lundi 30 décembre 2013 19:54:31 UTC+1, Owe Jessen a écrit :
If I remember the numbers correctly, about 1/3 of the web's sites are hosted with the help of wordpress. Insofar I'm curious if it would be feasable to integrate a shiny app - perhaps even as a wordpress plugin - into such an existing site. I think with this could be a great way to leverage the strengths of both worlds tremendously.

Joseph Lee

unread,
Dec 31, 2013, 1:53:21 AM12/31/13
to shiny-...@googlegroups.com
This works well; I use iframes on my own wordpress site.  The only downside I haven't figured out yet is how to make the iframe dynamically resize to match the shiny output.

Owe Jessen

unread,
Dec 31, 2013, 3:34:47 PM12/31/13
to shiny-...@googlegroups.com
Thanks for the reply, works nicely for a small blog post: http://www.econinfo.de/2013/12/31/clustering-whiskies-by-taste/

Jan Stanstrup

unread,
May 23, 2014, 5:39:00 PM5/23/14
to shiny-...@googlegroups.com
Did you ever figure out how to resize the iframe dynamically? I am trying to do exactly that too. I am using renderUI to update my output and it would be nice if I could add an appropriate script to resize the frame.

rmo...@lbl.gov

unread,
Nov 21, 2016, 12:17:47 AM11/21/16
to Shiny - Web Framework for R
This is probably no longer relevant to your problems, but considering I had spent quite some time to get the iframe for my shiny-app to resize correctly, I'm posting this answer for future reference.

My setup is the following:

I have a free shinyapps.io account and wanted to have a nice URL (instead of the ugly www.username.shinyapps.io/appname one) so I put up a website that basically just displays the shiny-app using an iframe. Thankfully, other people have been developing the necessary tools to do this (a big thanks to David Bradshaw). Download iframe-resizer from his website!

First, you have to set up the website which will point to the shiny-app. For this I simply modified one of the templates provided by David to look like this, the relevant parts are highlighted:

<!DOCTYPE html>
<html>
    <body>
        <div style="margin:5px;">
            <iframe id="nestedIFrame" src="LINK TO YOUR APP" width="100%" frameBorder="0" scrolling="no"></iframe>
        </div>

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script type="text/javascript" src="./ie8.polyfils.min.js"></script>
        <script type="text/javascript" src="./iframeResizer.min.js"></script>
        <script type="text/javascript">

             iFrameResize({heightCalculationMethod: "lowestElement"});

        </script>

    </body>
</html>

Make sure that all the necessary scripts ( ie8.polyfils.min.js, iframeResizer.min.js, downloaded from the iframe-resizer website ) are located within the same folder as the html-file, or to adjust the paths accordingly.

Next, you will have to include a line of code in your Shiny-app and create a folder "www". Create a folder called "www" in the main directory of your shiny-app (where app.R or your server.R and UI.R are located). Move the iframeResizer.contentWindow.min.js script into that folder. Now, add the following line of code to the main Panel (or equivalent) of your app, like this:

mainPanel(
      tags$body(tags$script(src="iframeResizer.contentWindow.min.js")),
...other stuff... )


And that's it. The iframe should automatically adjust its height to the size of the content inside the shiny-app, and the shiny-app will adjust to the width of the window.
Reply all
Reply to author
Forward
0 new messages