Iframe Shiny apps to Wordpress


#1

Hello Community,

I found out a little while back that I can combine two of my favourite things (Shiny apps and Wordpress) with a simple Iframe.

With this simple line I get my Shiny App inside a Wordpress page:

[iframe src="https://jiddualexander.shinyapps.io/junction_app/" width="100%" height="1000" frameborder="0" allowfullscreen="allowfullscreen"]

Looking through my pink glasses I see mostly positives:

  1. I can have data rich pages in a Wordpress website. Or in other words, I can add simple non-reactive content without making my shiny app more complex.
  2. I can have my one Shiny server (set up Dean Attali style http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/) run many Apps and Iframe them into multiple websites. Or similar with shinyapps io

Am I missing clear disadvantages, or do you think there are other robust and easy ways to do this? I'd love to hear your comments.

There are also thoughts/potentials that I'm not sure are possible but I'd love to explore with you guys. For example, could you have a user based Wordpress site with login where the Shiny app could also recognise the login?

Best,
Jiddu


#2

That's fine and people commonly do that. However, passing the login would not be possible AFAIK.


#3

We did something similar (embedding a model simulator in a tableau server dashboard).

Login was a bit tricky though.

In the end, we had two options:
1.) Make the Shiny app public, embed that and hope no one noticed or found it.
2.) Force users to use two accounts (once for Tableau, one for Shiny (connected to our company SSO for internal users))

It really wasn't a decision for us (had to go with #2).
If what was in the app itself was not sensitive in any way (ie, a interactive visual of public or user provided data), I could see going with option 1 though.


#4

Hi Jiddu. I am attempting to replicate your [iframe] shortcode implementation on my company's WordPress site, which is a completely new environment for me. Do you have a recommended plugin to enable this shortcode to work most effectively with Shiny apps?

Thanks,
Blake


#5

Hi Blake,

I actually use a bit of php code now. It's simple.

Install plugin: php code snippets

Start a new page in Wordpress. I commonly choose template 'blank slate' (in page attribute box) to make the complete page the Shiny app. Then when you edit the page set the editor to 'text' (not visual) and write:

[insert_php]

echo '< div style="margin-top:0px;">< iframe src="< shiny-app-url >" style="position: absolute; height: 100%; border: none; width: 100%;"></ iframe></ div>';

[/insert_php]

I use this php snippet because you can actually pass parameters to Shiny your shiny app. With the following:

[insert_php]

echo '< div style="margin-top:0px;">< iframe src="< shiny-app-url >/?' . $_SERVER['QUERY_STRING'] . '" style="position: absolute; height: 100%; border: none; width: 100%;"></ iframe></ div>';

[/insert_php]

This means that www.yourwebsite.com/my_shiny_input_id=10 starts your app with that input set.

Best,
Jiddu


#6

Thanks so much for the comprehensive response, Jiddu. The php method is not something that I had seen before. Looks like it could provide additional functionality that would be beneficial.

I appreciate your time and feedback!

Take care,

Blake


closed

This topic has been closed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.
#7