Loading extension dynamically


      I want to load extensions dynamically, list of extension to load will be taken from database. i am able to load extensions but getting problem while applying layout. And the extensions can be placed anywhere on form which will be decided at runtime.

    so can any one help me with that.

Thank you in advance.

What do you mean by "load extensions dynamically"? Could you elaborate the problem you encountered?

I mean to say there will be many extensions present in protected/extensions folder and the list of extension to load on page will be fetched from the database, the database will contain the list of extensions with there name and path. and also the place where it should be placed like left pane or right etc.

      lets say i fired a query and got result that i have to load a 'login' extension in right pane then i should be able to load that extension in right pane of the page. page is be divided into five parts like right pane, left pane, header, footer and body. and extensions could be loaded in any of this parts.

so the problem is i have the extension but don't know how to load them at runtime at correct location (left,right pane etc.) .


I think what you meant is portlet. Do not confuse it with extension. The latter is oriented for developers (it's like third-party libraries, which can be anything).

You may implement this by placing the following code in your main layout (roughly):

<div id="left-sidebar">

<?php foreach($this->getPortlets('left') as $portlet): ?>

<?php $this->widget($portlet->className, $portlet->properties); ?>

<?php endforeach; ?>


Now you need to implement getPortlets() in your base controller class, which should fetch information about portlets from database.

hello qiang

      Thank you for you reply.

      I'll try to do that.