I want to create a forum from a new extension

Discussion forum for Extension Writers regarding Extension Development.
edzela
Registered User
Posts: 110
Joined: Thu Aug 28, 2014 10:00 am

I want to create a forum from a new extension

Post by edzela »

Hi guys,
I am creating a new extension and from it I want to create a new extension, I was trying to do this but is not working, please any ideas? The problem is that form_helper is not working, i think because I don't have the folder /phpbb/form/helper
I am getting this message: You have requested a non-existent service

I am using phpbb 3.2.8

or there is another way to do it?.

Please advise

thanks a lot in advance!

Code: Select all

	global $phpbb_container;

		$this->container = $phpbb_container;

		$form_helper = $this->container->get('form_helper');

		// Set the form data
		$form_data = array(
			'forum_name' => $permalink,
			'forum_desc' => 'This is my new forum',
			'parent_id' => 67, // set the parent forum ID here
		);

		// Build the form
		$form_helper->set_form_key('acp_forums');
		$form_helper->add_hidden_field('mode', 'new');
		$form_helper->add_hidden_field('i', 'acp_forums');
		foreach ($form_data as $key => $value) {
			$form_helper->add_text_field($key, $value);
		}

		// Submit the form
		$form_url = append_sid($phpbb_root_path . 'adm/index.php');
		$response = $form_helper->submit_form($form_url);

		// Check for errors
		if ($response->get_error_code() !== false) {
			// There was an error creating the forum
			echo 'Error: ' . $response->get_error_message();
		} else {
			// The forum was created successfully
			echo 'Forum created successfully';
		}
User avatar
warmweer
Jr. Extension Validator
Posts: 11999
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: I want to create a forum from a new extension

Post by warmweer »

edzela wrote: Mon May 15, 2023 3:23 am I am creating a new extension and from it I want to create a new extension,
Wouldn't it be logical to finalise creating your (first) extension, test that thoroughly and then develop the second one?

Another thing is: what exactly do you want your extension(s) to do?
Your topic title mentions creating a forum from a new extension which is ambiguous to put it mildly.
An extension works within a board and it sounds as though you want to be able to create a new board programmatically from within the already existing board which implies creating a directory for the files (and uploading), creating a database to use, or using the same database with a different table_prefix, creating the config.php, etc...
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.

Return to “Extension Writers Discussion”