How to include sidebar modules from one entity to the sidebar of other entitity

From my theme I want to say it which sidebar elements are going to show in which sidebars. In addition, I want to show them dinamically (for example, put the ones of the pages in the sidebar of files). The documentation doesn't explain much to me or I don't know where to search.

I search the flow for the visualization of the elements of the sidebar, and I see that in the "page_handlers" functions of the entities a view of an element of the sidebar is called, depending of the "page_handler function". I want to avoid overwriting all libraries of the entities or unregistering the "page_handler" and create mine. Otherwise, I don't understand which view structure is load (one_layout, one_sidebar, ...) when parameter 'content' is passed to elgg_view_layout().

In one_sidebar.php is '$vars['sidebar']' that contains all the HTML that is going to show in the sidebar. I suppose that it is load by "echo elgg_view_module('sidebar', $title, $body, $vars)". They are load when the view that contains them are load in the "page_handlers". If  I'm wrong, then I'm lost.

I don't find the way to do what I want. I see the RiverAddon plugin but it generates a layout of three columns. In this momet I don't want this layout. I want one_sidebar.

Is there anyone that knows to do this in a good way?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking