Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-01-08 10:49:48

bashirnoori
Member
From: Afghanistan
Registered: 2012-10-02
Posts: 79

Contact Form Plugin

Is there any plugin of contact form to list the records ?
Like, visitors should submit the form and we receive that through email + list all submitted forms in the textpattern admin panel.
I went through https://plugins.textpattern.com/ but didn’t find.

Last edited by bashirnoori (2023-01-08 10:54:44)

Offline

#2 2023-01-08 11:45:01

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,540
Website GitHub Twitter

Re: Contact Form Plugin

Hi

There is com_connect for contact form, and i use my own plugin to save those data into db. I can give my plugin but you should modify it as you need.

Cheers.

Offline

#3 2023-01-09 09:43:10

ibadullah
Member
From: Kabul, Afghanistan
Registered: 2017-09-16
Posts: 49

Re: Contact Form Plugin

exactly i need the same thing for my project, if someone help us in this matter we will be highly appreciate.

Offline

#4 2023-01-09 13:10:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Contact Form Plugin

I second what dragondz says. com_connect is the platform you need to provide the means of capturing the form data. All you need is an extension that hooks into the delivery mechanism to siphon the records off into the database. And add an interface so you can browse them.

I didn’t realize you had a module to do that. I’d love to see it, if you don’t mind.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2023-01-09 14:41:19

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,540
Website GitHub Twitter

Re: Contact Form Plugin

Hi

here is the php code :

<?php

// This is a PLUGIN TEMPLATE for Textpattern CMS.

// Copy this file to a new name like abc_myplugin.php.  Edit the code, then
// run this file at the command line to produce a plugin for distribution:
// $ php abc_myplugin.php > abc_myplugin-0.1.txt

// Plugin name is optional.  If unset, it will be extracted from the current
// file name. Plugin names should start with a three letter prefix which is
// unique and reserved for each plugin author ("abc" is just an example).
// Uncomment and edit this line to override:
$plugin['name'] = 'dzd_mailtodb_inscrit';

// Allow raw HTML help, as opposed to Textile.
// 0 = Plugin help is in Textile format, no raw HTML allowed (default).
// 1 = Plugin help is in raw HTML.  Not recommended.
# $plugin['allow_html_help'] = 1;

$plugin['version'] = '0.1';
$plugin['author'] = 'Rabah (Dragondz)';
$plugin['author_uri'] = 'https://ix-dz.com';
$plugin['description'] = 'Nouveau inscrit';

// Plugin load order:
// The default value of 5 would fit most plugins, while for instance comment
// spam evaluators or URL redirectors would probably want to run earlier
// (1...4) to prepare the environment for everything else that follows.
// Values 6...9 should be considered for plugins which would work late.
// This order is user-overrideable.
$plugin['order'] = '6';

// Plugin 'type' defines where the plugin is loaded
// 0 = public              : only on the public side of the website (default)
// 1 = public+admin        : on both the public and admin side
// 2 = library             : only when include_plugin() or require_plugin() is called
// 3 = admin               : only on the admin side (no AJAX)
// 4 = admin+ajax          : only on the admin side (AJAX supported)
// 5 = public+admin+ajax   : on both the public and admin side (AJAX supported)
$plugin['type'] = '0';

// Plugin "flags" signal the presence of optional capabilities to the core plugin loader.
// Use an appropriately OR-ed combination of these flags.
// The four high-order bits 0xf000 are available for this plugin's private use
if (!defined('PLUGIN_HAS_PREFS')) define('PLUGIN_HAS_PREFS', 0x0001); // This plugin wants to receive "plugin_prefs.{$plugin['name']}" events
if (!defined('PLUGIN_LIFECYCLE_NOTIFY')) define('PLUGIN_LIFECYCLE_NOTIFY', 0x0002); // This plugin wants to receive "plugin_lifecycle.{$plugin['name']}" events

$plugin['flags'] = '0';

// Plugin 'textpack' is optional. It provides i18n strings to be used in conjunction with gTxt().
// Syntax:
// ## arbitrary comment
// #@event
// #@language ISO-LANGUAGE-CODE
// abc_string_name => Localized String

/** Uncomment me, if you need a textpack
$plugin['textpack'] = <<< EOT
#@admin
#@language en-gb
abc_sample_string => Sample String
abc_one_more => One more
#@language de-de
abc_sample_string => Beispieltext
abc_one_more => Noch einer
EOT;
**/
// End of textpack

if (!defined('txpinterface'))
        @include_once('zem_tpl.php');

# --- BEGIN PLUGIN CODE ---
/*<?** /*
	Registers the callback. dzd_mailverif_function() is
	now loaded on 'zemcontact.submit' event. You can find
	the callback spot from ZRC's source and what it can offer.
*/

register_callback('dzd_mailtodb_inscrit','comconnect.submit');

/**
	The function that does the work on
	the submit event
*/

function dzd_mailtodb_inscrit() {


	$evaluation =& get_comconnect_evaluator();

	/*
		It's spam, end here
	*/

	if($evaluation->get_comconnect_status() != 0)
		return;

	/*
		Saving the data goes here etc..
		$com_connect_values global etc. can be
		used to get the data and so on.
	*/

	global $com_connect_values;

	$if_ins = $com_connect_values['dzd_mailtodb_inscrit'] ? 1 : 0;

	if ($if_ins)
	{
		$values = doSlash($com_connect_values);

		$expvar = var_export($values, true);

		$myid = safe_insert(
						"inscrit",
						"date          = now(),
						nom            = '$values[nom]',
						prenom         = '$values[prenom]',
						societe        = '$values[societe]',
						adresse        = '$values[adresse]',
						wilaya         = '$values[wilaya]',
						activite       = '$values[activite]',
						autres         = '$values[autres]',
						tel            = '$values[telephone]',
						email          = '$values[email]',
						rc             = '$values[rc]',
						nif            = '$values[nif]',
						ai             = '$values[ai]'"
				);

		if ($myid<>''){
			$com_connect_values['insertion'] = 'Votre formulaire a été enregistré';

		} else {
			$com_connect_values['insertion'] = 'En Attente : Erreur insertion DB'.$expvar;
		}
	}
}
# --- END PLUGIN CODE ---
if (0) {
?>
<!--
# --- BEGIN PLUGIN HELP ---

# --- END PLUGIN HELP ---
-->
<?php
}
?>

I can send you the txt file if you want.

If you need advice on how to modify it i can tells you what to change and how to use it.

Cheers.

Offline

#6 2023-01-09 15:22:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Contact Form Plugin

Okay cool, so that simply stashes each of the passed fields into the ‘inscrit’ database table, which presumably you’ve set up previously with the columns that match your form. Nice. That should be easy to modify to match the table structure in bashirnoori’s case.

Unfortunately, making this process more generic is difficult. The latest plugin version has <com::connect_fields> which allows you to iterate over the passed form data, but I’m not sure if it’s callable from the submit callback. Even if it was, the database table must be tightly integrated with the form, because any new or renamed fields you supply in the form must be changed in the database so the records can be stored.

I don’t really know of a neat way around this. Creating columns on the fly is fraught with issues, especially since the sent data could be spoofed. But maybe if there was some back-end UI that allowed you to create columns – essentially a sort of com_connect table manager – then you could create as many fields as you need for as many contact forms as you have, and store the data in the relevant columns on submission. And the UI could allow you to browse/search the records too, perhaps.

It’s quite an undertaking, though. The other option is to use a generic table that has the primary contact details like name, email, phone, comments, etc, and then a single remaining column that contains the concatenation of all the other fields. That way, if you start changing the contact form fields, by adding or renaming fields for example, the data will still get through to the database (as long as the primary fields don’t change). It’s not as neat and makes searching more difficult, but it would work.

It all depends on your reason for wanting to store the data in the database. Remember you can send the message content to multiple email addresses by comma-separating them in the to field. So you could perhaps send a copy to an email address attached to a script whose sole purpose was to parse the message and add it to a database somewhere. That might be a bit far fetched!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2023-01-10 06:16:17

ibadullah
Member
From: Kabul, Afghanistan
Registered: 2017-09-16
Posts: 49

Re: Contact Form Plugin

Hi Dragondz, can you please share a txt file of your plugin?

Offline

#8 2023-01-10 10:43:41

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,540
Website GitHub Twitter

Re: Contact Form Plugin

Hi

Here it is :


# Name: dzd_mailtodb_inscrit v0.1 
# Type: Public plugin
# Nouveau inscrit Warchatic
# Author: Rabah (Dragondz)
# URL: https://ix-dz.com
# Recommended load order: 6

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

YToxMTp7czo0OiJuYW1lIjtzOjIwOiJkemRfbWFpbHRvZGJfaW5zY3JpdCI7czo2OiJhdXRo
b3IiO3M6MTY6IlJhYmFoIChEcmFnb25keikiO3M6MTA6ImF1dGhvcl91cmkiO3M6MTc6Imh0
dHBzOi8vaXgtZHouY29tIjtzOjc6InZlcnNpb24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IiI7czozOiJtZDUiO3M6MzI6ImRkM2VjODBkOThk
ZWY5NzU5NGJkYjM3ZDQ2MDFmNzJlIjt9

Offline

#9 2023-01-29 08:01:45

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Contact Form Plugin

I kindly request textpattern team, if possible to develop such plugin as many people need that.
Some months ago, I also had a client required a public form to submit and display the data on admin panel, I searched a lot and tried with textpattern but I didn’t success with textpattern, unfortunately I prepared that website with Wordpress.
So, it’s better if the TXP Team consider that.

Offline

#10 2023-01-29 11:59:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Contact Form Plugin

How did the WordPress solution work? If we had an idea of that, it might help limit the scope of the plugin. Think about these kind of things:

  • com_connect can be used to design any input fields just by changing a form or the tag’s container. So if someone adds a new field or renames one or removes one, how would that change get reflected in the database table that is used to capture that field?
  • com_connect can be used to capture content from multiple forms. Again, how does this get captured in the database? Does it all go into one table? Multiple tables; one per contact form? What if you delete a form, does the table and data get deleted too?
  • Is data mapped one-to-one (one field to one column in the database)? If you capture forename and surname separately in the contact form, does it get combined into a single ‘name’ field in the database – the concatenation of forename+surname input fields? Also, vice versa, what if you capture ‘Name’ in the contact form and want to split it into Prefix, Forename, Surname and Suffix columns in the database?

These are just a few of the issues that would need solving to bring such a plugin to life. So if we know how the WP plugin operates (and how successful it is at coping with change) it might give us some ideas on how to approach such a plugin here. I suspect it would be tricky to marry the back end and front end form generation as it currently stands and would need some kind of form builder middleware to tie them together.

Remember, com_connect is not just a contact plugin. It can be used for sign-ups, subscriptions, newsletters, third-party mass mail integration, …


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2023-01-30 08:50:34

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Contact Form Plugin

I used the eForm – WordPress Form Builder it has lots of feature and options, but all those are not required for TXP users, at least if you work to list the data of com_connect in txp admin panel like etc_tree in a separate menu, that would be great.
I’m sure lots of TXP users may need a form to enter data and list the information on admin panel, like Contact form, Newsletter, Survey, etc…

Anyhow, maybe the following plugin will give you an idea.
https://demo.eform.live/

Offline

#12 2023-01-30 09:21:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Contact Form Plugin

Thanks for the link.

Newsletter, subscription and survey management are related but slightly different from plain contact form information. I do have a newsletter plugin that is in very early stages of development (and has been for a while!) to replace bab_postmaster. Maybe there is scope to add a form builder of some description and store the data in Txp instead of in some third party system like MailChimp. It’s a lot of work though.

It would be nice if the storage endpoint could be independent of the capture. The admin panel that lists what data has been captured could be filtered using search if there’s a column for ‘source’ (i.e. which form or channel was used to send the data in). But that would require some API layer so the data could be pulled from either a Txp table or an external system. And with so many ways to store data, these would need to be modular so people could choose which system they want to host the data on. Tricky.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB