How to modify another plugin’s sidebar in my plugin without using overriding?

Hello everyone,
I am new in elgg, I have one problem I want to modify another plugin’s sidebar in my plugin without using overriding another one’s.
What should I do?

  • I'm not sure you correctly understand the mechanism of "overriding" a view. It doesn't mean making modifications to the original view file of the other plugin but it means you "replace" the original view completely by a view located "at the same place" in the views/default directory of your own plugin.

    It depends on what you want to achieve if there's alternative to overriding the other plugins view. One other way is "extending" the view. But this method leaves the original view unchanged. You can only add your own stuff either before or after the original view.

    Read about the possibilities of modifiying views at http://learn.elgg.org/en/stable/guides/views.html#altering-views-via-plugins. Maybe that clarifies your options.

  • Thanks for the reply  iionly
    If i use overriding method then one problem occur, if another plugin's owner change the code in sidebar then i must go to make those changes in myplugin also.
    So is their any option?

  • It really depends on what you want to achieve which option is best. The option to just extend a view is independent of changes in code in the other plugin's view (as long as the view is not removed). But you can't change the code / the output of the other plugin but only add your own code/output either before or after the other plugins code/output.

    The other options to alter a view described at http://learn.elgg.org/en/stable/guides/views.html#altering-views-via-plugins will give you more freedom but come at the price that you might need to change your own code in case the other plugin's code is changed. You don't necessarily have to change your code if the changes in the other plugin are irrelevant for you. But it depends on the changes made in each case. If altering the view input or output there might be no changes in your code necessary if the other plugin's view doesn't expect a different input and/or produces a different output. Nevertheless, the options described in the docs are the only options, if you don't want to modify the code of the other plugin directly - which is surely not recommended if you can reach your goal with any of the options described as you would have to maintain the whole plugin then (merge any changes if the original plugin gets updated etc.).

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