Announcement

#1 2013-10-30 15:12:22

kaesi_jones
Member
2010-05-27
17

Embedding JotForm

Hi, I'm using JotForm and open a form on my homepage with "Additional Pages":

<script type="text/javascript" src="http://www.jotform.eu/jsform/33024099614856"></script>

Now I want to insert the piwigo-username in that form.
So I was told to create a PHP script that will take the username from the mySQL database and then to use that variable containing the value and append it on the form URL like this:

"http://www.jotform.eu/jsform/33024099614856?#input2=username"
with #input2 is a field in that form.

It also should be possible to use that embed code and append it from my PHP script.

<script type="text/javascript" src="http://www.jotform.eu/jsform/33024099614856?#input2=username"></script>

Unfortunally I don't know how to create that PHP-script to get the username and append it to the form URL.

Has anyone an idea?

Thanks,
kaesi_jones

Offline

 

#2 2013-11-01 03:22:08

EltonCris
Guest

Re: Embedding JotForm

Hi there!

My name is Elton, one of Jotform Support. Allow me to assist you with your inquiry. I am not quite familiar with Piwigo but I find it intuitive so here I've come up a workaround for you with the logged in username auto-filled to your form.

Here's how,

1. Install Additional Pages plugin via admin panel and then activate it
http://shots.jotform.com/elton/jotform-11-01-2013-06-28-17.png

2. Add a new page and paste this embed code. Click Here!

**I have already placed your formID and the name of the username field from your form on that code so you can embed it right away. If you'd like to use another form, simply replace the formID and the username field name e.g. benutzername.

Visual guide:
http://shots.jotform.com/elton/jotform-11-01-2013-10-11-04.png

3. Save and check if the form captures the username when you logged in.

Demo: http://lanac.us/piwigo ***Create an account, login and check the form page found on the left navigation bar, last menu.

I hope this helps. Let me know if this doesn't work so we can ask further support from Piwigo Team. Thanks!

 

#3 2013-11-01 14:53:48

kaesi_jones
Member
2010-05-27
17

Re: Embedding JotForm

Hello Elton,

thank you for that support. Your script in your demo works very fine, but in my form it doesn't.
By wondering why, I tried a very simple "document.write" syntax, but even that doesn't work so that I can't see the users name.
Do you have any ideas about it?


<script type="text/javascript">
function getloggedinID(){
var username = document.getElementById('mbIdentification').getElementsByTagName('p')[0].innerHTML;
var name = username.split(" ");
return name[1];
}
document.write(getloggedinID());
</script>


Thanks!

Offline

 

#4 2013-11-01 15:27:00

EltonCris
Guest

Re: Embedding JotForm

Sorry to hear that.

May I know the website URL where your form is embedded so I could check it here?  If you noticed, I am using javascript code to get the inner text of the "welcome username!" message found on the left navigation menu so I was suspecting the ID from that code is different from your page. May I also know if the form appears fine on your end? If the problem is only on the username capture, allow me to check your page so I will try to come up with another workaround.

But before that, you can try your form's iframe embed code. Please replace the first code with this: http://pastiebin.com/52730c164a118

Thanks!

P.S. You can send us an email at support[at]jotform[dot]com just in case you do not want to publicize your website URL. Thanks!

 

#5 2013-11-01 17:48:16

iEltonCris
Member
2013-11-01
3

Re: Embedding JotForm

Hi Kaesi,

I am truly sorry about my last reply. In case there's anything you need clarification with or if there's any part you didn't understand, please feel free to let me know. I would be glad to assist you further.

For your information, please refer to this guide on how to get your form iframe embed code on the form builder. http://www.jotform.com/help/148-Getting … Frame-Code

In case you're having difficulties with script embedded form not appearing on guest mode, the iframe embed code should help.

Let me know if you have further questions.

Thanks,
Elton

Offline

 

#6 2013-11-03 14:02:39

kaesi_jones
Member
2010-05-27
17

Re: Embedding JotForm

EltonCris wrote:

...  If you noticed, I am using javascript code to get the inner text of the "welcome username!" message found on the left navigation menu so I was suspecting the ID from that code is different from your page....

Hi Elton,
I think that`s it!.

On my website I use the theme "stripped" and the language is "German". If I switch it to the theme "Sylvia" and use the language "English" everything works fine!
Do you know how to change the script, that the "stripped"-Theme with the "German"-language also will work?

Thanks,
kaesi_jones.

Offline

 

#7 2013-11-05 07:17:00

iEltonCris
Member
2013-11-01
3

Re: Embedding JotForm

Hi Kaesi,

I am truly sorry for the delay and thanks for providing more details about the issue.

I have come up with another approach to display the logged in username to the form using this short plugin. This one is a little more flexible since this can be used on any templates.

First, embed your form using this code. This is the **link broken** of your form with the username function.

Code:

<script type="text/javascript">
function getusername(){
if (USERNAME != '') return USERNAME;
}
document.write("<iframe allowtransparency=\"true\" src=\"http://form.jotform.co/form/33024099614856?benutzername="  + getusername() + "\" frameborder=\"0\" style=\"width:100%; height:529px; border:none;\" scrolling=\"no\"></" + "iframe>");
</script>

In order for the username function to work, please add the following scripts to the following files.

On piwigo/include/functions_plugins.inc.php, append this code. Place it before the php end tag ?>

Code:

function js_username_prefilter_trigger() {
  global $template;
  $template->set_prefilter('header', 'js_username_prefilter');
}

function js_username_prefilter($content, &$smarty) {
  return preg_replace(
    '/</head>/',
    '</head> <script type="text/javascript"> var USERNAME = "{if isset($USERNAME)}{$USERNAME}{/if}"; </script>',
    $content
  );
}

Visual guide:
http://shots.jotform.com/elton/jotform-11-05-2013-14-00-01.png

----------------------------------------------------------------
On piwigo/plugins/AdditionalPages/main.inc.php, same as above, put it before the ending tag ?>.

Code:

add_event_handler('init', 'js_username_prefilter_trigger');

Visual guide:
http://shots.jotform.com/elton/jotform-11-05-2013-14-06-58.png
----------------------------------------------------------------

Demo: **link broken**

username: demo
password: demo

***Note: Undefined means guest or not logged in

If I can be of further assistance, don't hesitate to reply here. Regards!

Last edited by iEltonCris (2013-11-09 08:19:11)

Offline

 

#8 2013-11-05 14:07:42

kaesi_jones
Member
2010-05-27
17

Re: Embedding JotForm

Hello Elton,

after I added the code in "functions_plugins.inc.php" I got the result that there was no more graphics on the webpage, only text.

So I erased

function js_username_prefilter_trigger() {
  global $template;
  $template->set_prefilter('header', 'js_username_prefilter');
}

and the graphic appeared again.

What could that be?

Thanks,
kaesi

Offline

 

#9 2013-11-07 01:48:46

iEltonCris
Member
2013-11-01
3

Re: Embedding JotForm

Hi Kaesi,

Thanks for your reply.

I have no clue why it wasn't working since it seems to be fine on my demo, maybe some conflicts or different version? What's your Piwigo version? I am using Piwigo 2.5.3.

On the script there are two functions for piwigo/include/functions_plugins.inc.php file. Can you double check if it was placed before the end tag ?>. Try to copy this again and paste it on the mentioned file.

Code:

function js_username_prefilter_trigger() {
  global $template;
  $template->set_prefilter('header', 'js_username_prefilter');
}

function js_username_prefilter($content, &$smarty) {
  return preg_replace(
    '/</head>/',
    '</head> <script type="text/javascript"> var USERNAME = "{if isset($USERNAME)}{$USERNAME}{/if}"; </script>',
    $content
  );
}

However, if the problem still persist, I'd appreciate if you could paste here the error shown on the browser console tab? Just right click anywhere on your page, inspect element, this will bring up the developer tools  then go to console tab. If you can provide to me a test page, that'd be a big help so I can diagnose and check the problem on my browser.

http://shots.jotform.com/elton/jotform-11-07-2013-08-28-59.png

I'll await your reply. Thanks!

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact