Adding mailform on a page?

General questions about CMSimple
Post Reply
svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Adding mailform on a page?

Post by svasti » Mon Jul 08, 2013 4:58 pm

Hi,

I though it would be cool if one could put the mailform page on another page. May-be one would like to put some personalised text on top to the mailform...
Something like

{{{PLUGIN:mailform();}}}
or simply
{{{mailform();}}}

would be cool. Is there such a possibility? I know there are different plugins available, but as the code is already part of cmsimple, why dublicate if you don't need anything fancy.

svasti

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Adding mailform on a page?

Post by cmb » Mon Jul 08, 2013 5:20 pm

svasti wrote:I know there are different plugins available, but as the code is already part of cmsimple, why dublicate if you don't need anything fancy.
Indeed that's a reasonable thought. Unfortunately the mailform is written in a sequential programming style, so reusing the mailform is probably not easy. You might try something like the following:

Code: Select all

function mailform()
{
    global $pth, ...; // several variables required for the mailform

    include $pth['file']['mailform'];
    return $o;
}
(there may be a change to get it working by tuning it)

For CMSimple_XH 1.6 I have rewritten cmsimple/mailform.php to cmsimple/classes/Mailform.php (see the 1.6 branch). The chances to reuse this class are probably better, even if the class was not written for reuse (actually I have just encapsulated the existing code in a class, and divided it to a couple of methods). Something like the following might suffice:

Code: Select all

function mailform()
{
    include 'path-to-Mailform.php';

    $mailform = new XH_Mailform();
    return $mailform->process();
} 
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: Adding mailform on a page?

Post by svasti » Mon Jul 08, 2013 6:54 pm

Hi Christoph,

may be on could put something like this into some future version.

svasti

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Adding mailform on a page?

Post by cmb » Mon Jul 08, 2013 10:01 pm

svasti wrote:may be on could put something like this into some future version.
The first step to having it in a future version, is to put it on the roadmap. :) I've put it on the roadmap for CMSimple_XH 1.6. It should not take long to implement it, even if my suggestions from above are not sufficient, as some modifications of Mailform.php are necessary.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Adding mailform on a page?

Post by cmb » Tue Aug 06, 2013 10:08 pm

I have added XH_mailform() (r830). Just call it on a page:

Code: Select all

{{{XH_mailform();}}}
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply