include a webcore form inside a Wordpress post

I gave a try to TMS webcore to include a couple of custom pages inside wordpress pages.
I installed "Code Snippets" plugin to wordperfect to avoid direct editing
I created two code snippets:
a) One to include the Javascript file loading in the head tag of the produced page like the following:

add_action( 'wp_head', function () {  ?>
<script type="text/javascript" src="/root/Project1.js"></script>
<?php } ); 

b) one to include the javascript running just before the end of the element:

add_action( 'wp_footer', function () { 
global $post;
if ($post->ID ==1177) {?>
<script type="text/javascript">;

I have created a new page in Wordpress with the above ID and I included a custom html element with a

<div id="test"></div>

I created a subdirectory /root inside the wordpress and I changed the .htaccess to not produced a 404 error if a request is done for a resource inside this directory

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/root/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Now I created an one form with the wizard of TMS WEB FORM and in the form I used a Twebpanel with ElementID the "test" from the above DIV tag, I compiled the project and I put the Project1.js in the /root folder in the wordpress webpage

The wordpress is loading the wordpress's page, before javascripts starts, and after that I get the wordpress's 404 page with the webcore's controls in left upper corner of the page.

Any suggestions? Thank you in advance

In a default TMS WEB Core app, the first form is created upon starting and the first form will load the first form HTML file (unit1.html), so I suspect it is this file that could not be loaded from your WordPress site.

1 Like

How can we disable the loading of this unit1.html file? It is not needed anyway.

In your DPR create the form via:

It worked!!! Thank you a lot
A new world starts.... Now I should find out how to include and position webcore forms.

But I did not know about createNewForm, LSP does not show it (it shows VCL's functions).
Should I start using VSC instead of Delphi?

We added an improvement that in the next update, LSP in Delphi will also show CreateNewForm.

1 Like

Hello Dimitris,

I like to include a Webcore project inside a Wordpress website as well.

Are you able to include an explanation or example how you did it?
(Maybe a small project as zip file?)

I am stuck in making it work😕
Thanks a lot!

I needed something easy and fast for one page and I installed the Snippet plugin.
The code was very easy:

add_action( 'wp_footer', function () { 
global $post;
if ($post->ID ==1177) {?>
<script type="text/javascript">;

Thanks Dimitris!