Jump to content

Add tab to products config page in back office


Recommended Posts

Yes, there's a displayAdminProductsExtra hook that modules can use to add a new tab there. The module's name is used as the tab name and the content returned from the hookDisplayAdminProductsExtra function in the module will be displayed as the content of the tab.

  • Like 1
Link to comment
Share on other sites

Whats my modules configuration page link?

 

In my view ive got some jquery to send an ajax request

$(document).on('click', '#ajax_add_video', function(e) {
	e.preventDefault();
	var product_id = $('input[name=id_product]').val();
	var embed_code = $('#add_video').val();
	$.ajax({
		type: 'POST',
		url: '/modules/rvlvideos/rvlvideos.php&ajax=1&action=storevideo',
		data: {
			product_id: product_id,
			embed_code: embed_code
		},
		dataType: 'json',
		success: function(json) {
			console.log(json);
		}
	})
	return false;
});

Then in my module controller, /modules/rvlvideos/rvlvideos.php ive got an ajaxProcessStoreVideo() method

public function ajaxProcessStoreVideo()
{
	return 'GOT TO MY CLASS';
}

But when I click my #ajax_add_video button - my ajax response is a 404 page not found error....

Edited by jellyMan (see edit history)
Link to comment
Share on other sites

I think so, but to be honest, I've never actually tried it from a tab on the product editor. I just know that's how I perform AJAX requests on my module's configuration page. I would expect it to work from the the product editor as well. Since it's an AJAX request, it should return the results only and not load the entire configuration page.

Link to comment
Share on other sites

No there isn't a configuration page for my module...

 

My module is at the very early stages and it's my first one so I may be missing a lot out... but for now all im trying to achieve is this...

 

I have a new section on my product editing page called "RVL Videos".... i've got that loading in and displaying a simple form for that section.

 

The confirm just consists of a simple text field and a submit button....

 

On submit I want to run my storeVideo() method thats in my module and the field input to the database.

 

I havent registered it as an admin module and there is no configuration page.

 

Surely generating the url for the ajax request should be more simple than this - i dont get it.

Link to comment
Share on other sites

I guess your only solution is to create a separate PHP file in your module just to handle AJAX requests. For example, modules/storevideo/ajax.php with the following:

include_once('../../config/config.inc.php');
include_once('../../init.php');
include_once('storevideo.php');

$storevideo = new StoreVideo();

Then you can call public functions from your storevideo.php file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...