MyBB Community Forums

Full Version: quick question about codepress
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys, after reading in the MyBB Blog about codepress, I thought I'd experiment with it a little and implement it into one of my blog sites. How the heck did you guys (MyBB), get it to update php files? I know how to update php files but since this is javascript my php script that updates the php files doesn't work anymore. I know I need some type of javascript that will send the submit query to my php file but I'm not to familiar with php so I thought maybe someone here can throw it in. Shy
Best Regards.
I think you can send an AJAX request to a php handler with the new data and update it with that.
We had to use a handler to get the data and set it back locally (because it's setup within an iframe)

echo "<script language=\"Javascript\" type=\"text/javascript\">
	Event.observe('edit_template', 'submit', function()
	{
		if($('template_cp')) {
			var area = $('template_cp');
			area.id = 'template';
			area.value = template.getCode();
			area.disabled = false;
		}
	});
</script>";

This is using prototype in the templates file.

p.s. this is MyBB code, so you can't copy it
Jeff Wrote:I think you can send an AJAX request to a php handler with the new data and update it with that.

Exactly what I'm looking for. However, not to familiar with it. Any ideas on how to create the AJAX request?
Tikitiki Wrote:We had to use a handler to get the data and set it back locally (because it's setup within an iframe)

echo "<script language=\"Javascript\" type=\"text/javascript\">
	Event.observe('edit_template', 'submit', function()
	{
		if($('template_cp')) {
			var area = $('template_cp');
			area.id = 'template';
			area.value = template.getCode();
			area.disabled = false;
		}
	});
</script>";

This is using prototype in the templates file.

p.s. this is MyBB code, so you can't copy it
Don't worry about that, i'm an expert at ripping things just as much as Yuna and xam so that piece of code is nothing to me Smile
rcpalace Wrote:
Jeff Wrote:I think you can send an AJAX request to a php handler with the new data and update it with that.

Exactly what I'm looking for. However, not to familiar with it. Any ideas on how to create the AJAX request?

You can use a javascript framework (I use jQuery) which provides really easy to use AJAX functions.

When a user clicks the "submit" button, it launches a javascript function which would be your ajax call. Usually it is something like ajax.send('url', 'postdata');

The handler would be a php file that would take in a $_GET data or $_POST data and then process it.