Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Calling a widget in a plugin with a custom widget template?

  • timstallmann
  • timstallmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #173165 by timstallmann
Hi! I'm trying to build a plugin that creates a custom, simplified view of survey results on the admin side. I've managed to follow the tutorials and get the menu items created, and am trying to create a new TbListView widget to render the list of results, using code like this (inside my view template file)
Code:
 $this->widget('bootstrap.widgets.TbListView', array(
                'dataProvider' => $model->search(),
                'itemView' => 'support_request',
                'sortableAttributes' => array(
                'datestamp',
                        'FactoryName',
                        'City',
                ),
              ));

The problem I'm running into is when this code runs, the AdminController->getViewFile method gets called, and it's looking in /var/www/html/application/views for my view template file, which should be in plugins/modulename/views instead. Any idea how to resolve this? Do I need to create a custom controller for the plugin?
The topic has been locked.
  • timstallmann
  • timstallmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #173166 by timstallmann
Ok classic example of rubber-ducking a problem here, immediately after posting I realized that changing the itemView attribute to plugin_views_folder2.views.support_request solves the problem. But why?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
6 years 3 months ago #173206 by DenisChenu
Because pluigin are not Yii module, my way to do is
Code:
Yii::setPathOfAlias(get_class($this),dirname(__FILE__));
Yii::app()->controller->render(get_class($this).".views.myview",$renderData);

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • timstallmann
  • timstallmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #173518 by timstallmann
Nice!! Thanks!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
6 years 3 months ago #173528 by DenisChenu
:)

I don't know where you want to use it ? If it's out of public page : some insipration :
- gitlab.com/SondagesPro/managament/respon...tAndManage.php#L1473
- gitlab.com/SondagesPro/coreAndTools/renderMessage

To show a dynamic list even with twig : you need to do it out of twig i think. gitlab.com/SondagesPro/managament/respon.../content/surveys.php

Maybe we can add function to call widget in twig manager : github.com/LimeSurvey/LimeSurvey/blob/ma...S_Twig_Extension.php

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose