How to customize Strapi backend (content-manager) controllers, services and validation?

I have found an elegant way of doing this. I created a lifecyle-hook.
Therefore I’ve created a file src/api/artikel/content-types/artikel/lifecycles.js with the following content:

module.exports = {
	afterFindOne(event) {
		const { result, params } = event;
		
		new_blocks = Array();

		if (result.hasOwnProperty("Blocks")) {
			result.Blocks.forEach((element) => {
				element.identifier = " ID of Element: " + element.id;
				new_blocks.push(element);
			});

			result.Blocks = new_blocks;
		}
	}
};

I’ve added also an “identifier”-Tag with type string for each component. Then Strapi plugin-content-manager uses this Tag as a display name. As you can see in my code, I replace this tag with the string “ID of Element …”, so in dynamic zone now the ID of each component appears.

That’s all,
Thank you,
Have a good day,
Sven

1 Like