Page 1 of 1

Adding mailform on a page?

Posted: Mon Jul 08, 2013 4:58 pm
by svasti
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

Re: Adding mailform on a page?

Posted: Mon Jul 08, 2013 5:20 pm
by cmb
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();
} 

Re: Adding mailform on a page?

Posted: Mon Jul 08, 2013 6:54 pm
by svasti
Hi Christoph,

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

svasti

Re: Adding mailform on a page?

Posted: Mon Jul 08, 2013 10:01 pm
by cmb
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.

Re: Adding mailform on a page?

Posted: Tue Aug 06, 2013 10:08 pm
by cmb
I have added XH_mailform() (r830). Just call it on a page:

Code: Select all

{{{XH_mailform();}}}