This plugin, available from DataAcesss allows you to embed a DataFlex WebApp into a WordPress site. WordPress is a free open source content management system.

In order to use this plugin we need a WordPress site. To start we will simply install WordPress on the localhost.

Obviously you will need a computer with IIS installed and running.

Installing WordPress can often be very easy but sometimes a bit of a headache as well.

If all is ok you can use the Microsoft Platform Installer to install WordPress. Simply navigate to the Platform Installer in IIS Management and type WordPress into the search window.

Add WordPress and start the install. This will install all prerequisites required by WordPress such as PHP as well as MySQL.

If you are not so lucky the install fails. There is a common issue with the WordPress platform install where during the install an error is shown that tells you the password for the MySQL server is invalid.

if that happens to you there are several solutions to the problem. From manually installing MySQL and the .NET connector and then rerunning the platform installer to completely manually installing all items.

On my last test for this blog I was forced to install all pieces manually. I installed PHP from the platform installer and downloaded MySQL manually and installed it.

Next step is to create an empty database for wordpress. you can do this from the MySQL command line using the following commands

mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON databasename.* TO "username"@"hostname"
    -> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
  
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT

One a database is created you will need to manually edit your wp-config.php file and set the following entries

DB_NAME, DB_USER, DB_PASSWORD, DB_HOST

and also the Authentication Unique Keys

then download and unzip wordpress into the folder on your web site.

Then navigate in the browser to the wordpress install script

for example

http://mysite.com/wp-admin/install.php

if all is fine the wordpress install will start and finish in a short time.

Now that WordPress is up and running we need to configure it for using DataFlex for WordPress

Start by downloading DataFlex for WordPress at http://www.dataflex4wordpress.com/index.php/df4wp-plugin/

The zip file contains two files. DataFlex4wordpress.zip which is a plugin for wordpress and DF4WPLib.zip which is a library workspace needed to compile your DataFlex WebApp.

In your wordpress Dashboard select Plugins -> Add New

Then click Upload Plugin. Borwse to your DataFlex4wordpress.zip file and click Install Now

if WordPress asks for your FTP credentials your site user does not have rights to write to the wp-content folder. You can either use FTP access or assign proper rights and restart the install of the plugin

Once the plugin is installed click Activate Plugin

At this time you should see a new DataFlex option that was added to your Dashboard menu

We will get back to these settings later after we have ourt test application ready.

To get a test application we launch the DataFlex Studio. Remember to launch it as Administrator so it will be able to register your webapp.

Create a new Workspace. I called mine TestWP. Once the workspace is created create a new WebApp project.

We now need to add the DataFlex 4 WP library to this workspace. You can place the library in any location you like. We generally create a library folder inside our workspace folders.

Unzip the DF4WP.zip file into the library workspace and then add the library to the workspace.

Now open your webapp.src file and at the top use the cWPWebApp.pkg file

Use AllWebAppClasses.pkg
Use cWPWebApp.pkg

//Register_Object oDashboard

also change the class used for your WebApp from cWebApp to cWPWebapp

Object oApplication is a cApplication
End_Object

Object oWebApp is a cWPWebApp   
    Set psTheme to "Df_Flat_Touch"
    Set peAlignView to alignCenter

in addition any view that you would like to be able to show within your wordpress site needs to be based on the cWPWebView class and any modal dialogs need to be based on the cWBWebModalDialog class.

for testing I created a simple hello world view.

make sure your app runs properly and then lets go back to the WordPress dashboard.

In the DataFlex settings set the path to your application. For example /TestWP

then enter a 32 character secret. if you do not enter one, one will be automatically created.

New create a new page in WordPress and use the following shortcode to add your DataFlex application

[df4wp-webapp height=600]

now publish the page and navigate to the page. Your DF WebApp should be showing in the page

df4wp

Michael Salzlechner is the CEO of StarZen Technologies, Inc.

He was part of the Windows Team at Data Access Worldwide that created the DataFlex for Windows Product before joining StarZen Technologies. StarZen Technologies provides consulting services as well as custom Application development and third party products specifically for DataFlex developers