Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hello Everybody

We have two sites running with couchcms. One page has a form where the data is stored in cloned page. the other site should embed the same form. I tried doing it the following way:

A template named 'external-form.php' on the primary site:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Embeddable form on primary site' clonable='0'>
  <cms:editable name='formfield1' ... />
  ...
</cms:template>
<cms:embed form.html />
<?php COUCH::invoke(); ?>



The form itself is like the following:

Code: Select all
<cms:form
  masterpage='external-form.php'
  mode='create'
  enctype='multipart/form-data'
  method='post'
  anchor='0'
  action='http://url.to.primary.site/external-form.php'
>
  <cms:if k_success >
    <cms:db_persist_form
      _invalidate_cache='0'
      formfield1=frm_formfield1
      _auto_title='1'
    />
  </cms:if>
  <cms:input type="bound" id="formfield1" name="formfield1" />
</cms:form>



On the secondary site (separate couch intallation) I embed the form from the primary site in the following way:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Secondary site with embedded form from primary site' clonable='0'>
</cms:template>
<!doctype html>
<html lang="de">
  <head></head>
  <body>
    <?php echo file_get_contents("http://url.to.primary.site/external-form.php") ?>
  </body>
</html>
<?php COUCH::invoke(); ?>


The form is correctly embedded on the secondary site, but after submitting, couch sais that the session key is not correct.
It is important that the data filled in on the secondary site is stored in the database on the primary site.

Anybody an idea how to solve the problem with the session key?

Kind regards,
Oliver
Hi,

the problem is the first site doesn't have the same mysql connection as the second. I think you can get this only working by writing an extra connection in php.

Edit: or maybe "fake" one by pointing to an ajax form
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Form can be submitted in GET, instead of POST. If this is accepted, then I would personally do it with cms:gpc tag. And upon revalidation of received values, do database update with db_persist.
Did i make myself clear? I can work on this.
Same idea was expressed in this topic of mine. viewtopic.php?f=2&t=9893&hilit=+gpc Take a look, please.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: Form can be submitted in GET, instead of POST. If this is accepted, then I would personally do it with cms:gpc tag. And upon revalidation of received values, do database update with db_persist.
Did i make myself clear? I can work on this.
Same idea was expressed in this topic of mine. viewtopic.php?f=2&t=9893&hilit=+gpc Take a look, please.


Thank you for the tip. I almost got it working, at least for all non-checkbox fields. Values for checkbox fields are passed in multiple url parts. I do not see any way without using a form, but hten again I have the problem that the form cannot be received when coming from a request from another site. So I have to find a way to get the multiple values from checkboxes into a variable, or the pack them before sending, so that is sent in one field.

Does anyone have an idea how to achieve this?

Example of the url (when sent in get):
Code: Select all
http://site.com/receive_form_data_from_external_site.php?
schwerpunkt%5B%5D=Energieeffizienz&
schwerpunkt%5B%5D=Einbruchsicherheit&
schwerpunkt%5B%5D=Schallschutz&
gebaeudetyp=Gewerbeobjekt&
...
k_hid_kformname0=kformname0&
k_nonce=1a0fe90c5b1c8d0ed265a98efe7dadfe&
nc=1
Can you share how you got working the rest? It is very interesting, indeed. I think noone here tried to do it, at least publicly and you managed to switch from theory to practice. Really encouraging! Please tell me, what you achieved so far.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I found now a solution:

I changed the names of the checkboxes from schwerpunkt[] ... to schwerpunkt_1, schwerpunkt_2, ...

Then upon receiving the url parameters with gpc I put it together like so:
Code: Select all
<cms:set schwerpunkt_1="<cms:gpc 'schwerpunkt_1' />" />
<cms:set schwerpunkt_2="<cms:gpc 'schwerpunkt_2' />" />
<cms:set schwerpunkt_3="<cms:gpc 'schwerpunkt_3' />" />
<cms:set schwerpunkt_4="<cms:gpc 'schwerpunkt_4' />" />
<cms:set schwerpunkt="<cms:show schwerpunkt_1 />|<cms:show schwerpunkt_2 />|<cms:show schwerpunkt_3 />|<cms:show schwerpunkt_4 />" />


Then I save it in the database like so:
Code: Select all
<cms:db_persist
   _auto_title='1'
   _invalidate_cache='0'
   _masterpage='template.php'
   _mode='create'
   schwerpunkt=schwerpunkt
   ...
   />



The field in the template is defined as follows:
Code: Select all
   <cms:editable group='g_interests' order='1' type='checkbox' name='schwerpunkt' label='Schwerpunkt' required='0' opt_values='Energieeffizienz | Einbruchsicherheit | Schallschutz | Weiss nicht' />


It works now!
Congrats!
This piece can be rewritten:
Code: Select all
<cms:set schwerpunkt_1="<cms:gpc 'schwerpunkt_1' />" />
<cms:set schwerpunkt_2="<cms:gpc 'schwerpunkt_2' />" />
<cms:set schwerpunkt_3="<cms:gpc 'schwerpunkt_3' />" />
<cms:set schwerpunkt_4="<cms:gpc 'schwerpunkt_4' />" />
<cms:set schwerpunkt="<cms:show schwerpunkt_1 />|<cms:show schwerpunkt_2 />|<cms:show schwerpunkt_3 />|<cms:show schwerpunkt_4 />" />

with the use of Concat:
Code: Select all
<cms:set schwerpunkt_1="<cms:gpc 'schwerpunkt_1' />" />
<cms:set schwerpunkt_2="<cms:gpc 'schwerpunkt_2' />" />
<cms:set schwerpunkt_3="<cms:gpc 'schwerpunkt_3' />" />
<cms:set schwerpunkt_4="<cms:gpc 'schwerpunkt_4' />" />
<cms:set schwerpunkt="<cms:concat schwerpunkt_1 ' | ' schwerpunkt_2  ' | '  schwerpunkt_3  ' | '  schwerpunkt_4 />" />

Or directly:
Code: Select all
<cms:set schwerpunkt="<cms:concat "<cms:gpc 'schwerpunkt_1' />" ' | '  "<cms:gpc 'schwerpunkt_2' />" ' | ' "<cms:gpc 'schwerpunkt_3' />" ' | ' "<cms:gpc 'schwerpunkt_4' />" />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
So could you please share what you have achieved? Why do you need data pass from one domain to another?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi trendoman

I need it for the following scenario:

We have several sites that have a customized form input. They generate 'leads' which are then send to a central backend site (a standalone couchcms instance) and stored in the central db. There we manage the leads like assigning to our partners, sending mails, etc. With this solution, the websites are just 'websites', and the whole customer data is managed within one single backend site.

With this solution data backup ist also smaller an can be done centrally. Employees managing the customers and partners cannot accidentally change content of the websites.
Thank you! Very interesting!

BTW, have you seen Google Forms? https://www.google.com/forms/about/ Very interesting tool to collect info into a spreadsheet and have charts.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
10 posts Page 1 of 1