Hi community..

 

I'm using a marketplace add-on, and want to customize one of their page.

In that page, there is a button that implement a custom handler. And how to modify/override that custom handler in my custom package?

For that page i have make it available in my custom package, but when i switch to code (client schema) i didn't find that handler.

Is it possible?

Like 0

Like

1 comments

You won't see the handler in your replacing page, however, you can still override it. For example, if the base page has a request called this: 

{
	request: "usr.MyCustomRequest",
	handler: async (request, next) => {
		// code is here
 
		return request?.handle(next);
	}
}

In your code in the replacing page, you could add:

{
	request: "usr.MyCustomRequest",
	handler: async (request, next) => {
		// YOUR code here, as needed
 
		// the line below calls the base page's handler
		return request?.handle(next);
	}
}

If you don't want the base page's handler to run, just omit the line below in your code:

return request?.handle(next);

Then with that line gone in your handler in the replacing page, the base page's handler won't run at all since it won't get called. If you still want it to run, but then your code does other stuff after it is done, you could do this: 

{
	request: "usr.MyCustomRequest",
	handler: async (request, next) => {
		// let base page handler run first
		const result = await request?.handle(next);
 
		// now do your stuff
 
		return result;
	}
}

Hopefully, that makes sense.

Ryan

Show all comments