Modules and return_id

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Nexonen

Modules and return_id

Post by Nexonen »

Hi,

I'm hoping someone can help me out here.

I have written my own module to take some data from a form and email it.

The form is part of the template. In the template I use {cms_module module="EmailComments"}. I started the form using echo $this->CreateFormStart($id, 'sendemail', $return_id); in the module.

When the form is submitted, I want it to print some text where I put {cms_module module="EmailComments"} in the template. This bit works. The trouble I'm having is it also prints the text where {content} is, and I want it to display the content that the user was viewing.

The code I have in the module is this:

Code: Select all

function DoAction($name, $id, $params, $return_id='')
	{
		$db = $this->cms->db;
        echo $this->CreateFormStart($id, 'sendemail', $return_id);

		switch ($name)
		{
			case 'sendemail':
            echo "<p style=\"font-size: x-small; color: red;\">Thank you. Your message has been sent.</p>";
            	//mail("emailaddresshere", "Email form", "From: $email\n\nComments: $comments");
		}
	}
I am confused as to what $return_id means. I have read a few posts here on it but they didn't answer my question.

Can anyone help me to get it to return the content of the page the user was on, instead of printing the output of the module where {content} was?

Thanks very much.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Modules and return_id

Post by Ted »

Submitting a form will automatically go to moduleinterface, which basically means the module takes over.  If you want it to be "inline" instead, do: CreateFormStart($id, 'sendemail', $return_id, 'post', '', true);

The last true is the inline parameter.

$return_id is the id of the page the module was first invoked.  It's so modules that take over know where to redirect back to when they're finished.
Nexonen

Re: Modules and return_id

Post by Nexonen »

Thank you very much!

That code works perfectly :D
Locked

Return to “CMSMS Core”