Welcome, Guest
Username: Password: Remember me

TOPIC: Create a new view in plugin

Create a new view in plugin 4 months 3 days ago #106827

  • elvey
  • elvey's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
I'm developing a plugin that requires me to create an additional view. Unfortunately documentation on the plugin environment is a little slim and I can't find for the life of me how to create a new view/controller in my plugin.
Would someone be able to point me towards the appropriate resources for this task? Thanks you
The administrator has disabled public write access.

Create a new view in plugin 4 months 2 days ago #106876

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6231
  • Thank you received: 793
  • Karma: 238
Hi,

There are no existing included solution actually, have some hack to do it actually

Starting by
$aData['clang'] = $clang = Yii::app()->lang;
            $aData['sImageURL'] = Yii::app()->getConfig('adminimageurl');
            $aData['surveyid']=$aData['iSurveyID']=$aData['iSurveyId'] = $this->iSurveyId;
            $sViewPath = '/admin/survey';
            $oAdminController=new AdminController('admin');
            $oCommonAction = new Survey_Common_Action($oAdminController,'survey');
The administrator has disabled public write access.

Create a new view in plugin 4 months 23 hours ago #106914

  • elvey
  • elvey's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Thanks for your help. I will however ask for a little more guidance if possible.

I am guessing this is creating a new action which is then saved to the admin controller. However I am unsure where the action code is set. Is there a parameter I can use to set a callback method? Otherwise I see most existing actions have classes that extend Survey_Common_Action in application/controllers/admin so could I create another class such as this that can be loaded from within my plugin directory?

Finally I'm not sure what to do with $sViewPath. Should this be set in $aData?
The administrator has disabled public write access.

Create a new view in plugin 1 month 2 weeks ago #109957

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
Any luck with creation of new view? I'll looking to create a plugin and will need to create a nev view in admin area...
elvey wrote:
Thanks for your help. I will however ask for a little more guidance if possible.

I am guessing this is creating a new action which is then saved to the admin controller. However I am unsure where the action code is set. Is there a parameter I can use to set a callback method? Otherwise I see most existing actions have classes that extend Survey_Common_Action in application/controllers/admin so could I create another class such as this that can be loaded from within my plugin directory?

Finally I'm not sure what to do with $sViewPath. Should this be set in $aData?
The administrator has disabled public write access.

Create a new view in plugin 1 month 2 weeks ago #109961

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6231
  • Thank you received: 793
  • Karma: 238
In one of my old plugin (surely need better suystem and adpatation, i use this (adding a new page for survey)
private function displayContent($aData=false)
        {
            if(!$aData){$aData=array();}
            $aData['clang'] = $clang = Yii::app()->lang;
            $aData['sImageURL'] = Yii::app()->getConfig('adminimageurl');
            $aData['surveyid']=$aData['iSurveyID']=$aData['iSurveyId'] = $this->iSurveyId;
            $sViewPath = '/admin/survey';
            $oAdminController=new AdminController('admin');
            $oCommonAction = new Survey_Common_Action($oAdminController,'survey');
            ob_start();
            //header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding
            $oAdminController->_getAdminHeader();
            $oAdminController->_showadminmenu($this->iSurveyId);
            if($this->iSurveyId)
                $oCommonAction->_surveybar($this->iSurveyId);
            if($this->fContent){
                self::render($this->fContent,$aData);// Surely better with ->render ....
            }
            $oAdminController->_loadEndScripts();
            $oAdminController->_getAdminFooter('http://manual.limesurvey.org', $clang->gT('LimeSurvey online manual'));
            $sOutput = ob_get_contents();
            ob_clean();
            App()->getClientScript()->render($sOutput);
            echo $sOutput;
            Yii::app()->end();
        }
        private function render($file,$aData=false){
            if($aData)
            {
                foreach($aData as $data=>$value){
                    $$data=$value;
                }
            }
            include_once(dirname(__FILE__)."/".$this->fContent);// Surely better with ->render ....
        }
Last Edit: 1 month 2 weeks ago by DenisChenu.
The administrator has disabled public write access.
Time to create page: 0.238 seconds
Donation Image