Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iframe in wordpress website don't work #473

Closed
fcreach opened this issue Jan 23, 2024 · 5 comments
Closed

Iframe in wordpress website don't work #473

fcreach opened this issue Jan 23, 2024 · 5 comments

Comments

@fcreach
Copy link

fcreach commented Jan 23, 2024

Hello,

I am sorry for this request, but I was not able to resolve my problem by following the documentation and recommendations read.

I'm trying to integrate appointments into an iframe with a WordPress site.

The appointment url: https://docs.myservernextcloud.net/index.php/apps/appointments/embed/gwiLZ%2BaPwbDlRsk%3D/form

The website url: https://www.soudomaine.domaine.fr
The page of the website url: https://www.soudomaine.domaine.fr/index.php/page-d-exemple/
My nexcloud user: toto

I did this:
On nextcloud php occ config:app:set appointments "emb_afad_toto" --value "www.soudomaine.domaine.fr"
And php occ config:app:set appointments "emb_cncf_toto" --value "https://www.soudomaine.domaine.fr/index.php/page-d-exemple/?some_param_name="

On wordpress. In the header `
_<script type="text/javascript" async="async">
var urlRDV = window.location.href.includes('index.php/page-d-exemple/');
if (urlRDV) {
window.addEventListener('DOMContentLoaded', function() {
var src = "https://docs.myservernextcloud.net/index.php/apps/appointments/embed/gwiLZ%2BaPwbDlRsk%3D/form";
var appointmentParam = "apphash"

function getUrlVars() {
  var vars = {};
  var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
    vars[key] = value;
  });
  return vars;
};

var params = getUrlVars();
var apphash = params[appointmentParam];
var paramsConcat = Object.entries(params).reduce(function (prev, curr) {
  if (curr[0] === appointmentParam) {
    return prev;
  }
  prev = prev.concat("&",curr[0].toString(),"=",curr[1].toString());
  return prev;
}, "");

if (apphash) {
  src = src.slice(0, -4).concat('cncf?d=').concat(apphash,paramsConcat);
 }

var myIframe = document.getElementById('myAppointmentFrame');
myIframe.src=src;

})();
}

</script>_
`

On the page <iframe id="myAppointmentFrame" title="Appointment form" frameborder="0" style="height: 100rem; width: 100%;" src= "https://docs.myservernextcloud.net/index.php/apps/appointments/embed/gwiLZ%2BaPwbDlRsk%3D/form" name="myAppointmentFrame"></iframe>

In the iframe, the message "docs.myservernextcloud.net does not allow connection." appear.

Can you help me please ?
Thank you

@fcreach
Copy link
Author

fcreach commented Jan 23, 2024

I have tested with the php code and it's the same error.
<?php $src = 'https://docs.myservernextcloud.net/index.php/apps/appointments/embed/gwiLZ%2BaPwbDlRsk%3D/form'; $iframe_class = "iframe_form"; $key_name = "my_param_key"; if (isset($_GET[$key_name])) { // Email Confirm/Cancel button was clicked $src = substr($src, 0, -4) . 'cncf?d=' . urlencode($_GET[$key_name]); $iframe_class = "iframe_confirm"; } echo '<iframe id="my_iframe" class="' . $iframe_class . '" src = "' . $src . '"></iframe>'; ?>
An idea ?
Thanks.

@SergeyMosin
Copy link
Owner

@fcreach Can you send me the real URLs to sergey [at] srgdev.com

@fcreach
Copy link
Author

fcreach commented Jan 24, 2024

Thank you @SergeyMosin . I have send the message.

@fcreach
Copy link
Author

fcreach commented Jan 24, 2024

@SergeyMosin. I have resolved my issue. It was because the first time i have inject the occ line the url was wrong. And the next time when i injected the good line it not was take by nextcloud without error message.
So i have delete the parameters of the app with config:app:delete and inject the good line and it's works now !

Sorry for th derangement and thank you for your intervention.
I hope that my error can help at another one.

@fcreach fcreach closed this as completed Jan 24, 2024
@stefangweichinger
Copy link

stefangweichinger commented Mar 1, 2024

I hope that my error can help at another one.

Found this issue as I also see errors trying to embed my URL ...
Will try to follow your approach but so far I don't fully understand.

May I add my URLs ...

nextcloud: https://oc.oops.co.at/nextcloud/

appointments: https://oc.oops.co.at/nextcloud/index.php/apps/appointments/pub/ilXXXXXX%3D%3D/form

wordpress: https://www.oops.co.at

user in nc: sgw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants