Jul 29, 2008

Using an extension from another extension

From time to time I notice that many extensions duplicate certain functionality. For example, many extensions have a page browser. Some of them use page browser provided by pi_list_browseresults function from tslib_pibase class. Examples include mininews, indexed search and tt_news. That function is hard to customize, so almost everyone creates a new page browser.

I came across it again this week. While creating a new extension I had to use a page browser. I have several page browsers already (in comments and some other extensions). But I do not like copying the code. If error exists in the code I will have to update all places where I copied the code.

Next I thought: it would be great if an extension could provide certain functionality to other extensions. For example, if I make a universal page browser, it could be used from any other extension.Therefore I sat down and coded universal page browser. It is alpha state now and not yet in TER. I will test it a little more, write a manual, create demo extension and upload everything to TER. I think I will even create a tt_news hook to use this new page browser in tt_news.

After making the page browser I though it would be great if there are more extensions like this. Just imagine: you need to focus only on coding your own functionality. You do not have to care about coding suplemental things like page browser or ratings. You just reuse them! It speeds up your development and makes errors less likely to appear in the your code.

For now I see several extensions that can be reused by other extensions:
  • comments
  • page browser (will be available soon!)
  • ratings
Can anyone propose other entries to this list?

No comments:

Post a Comment