View Issue Details

IDProjectCategoryView StatusLast Update
13521Bug reports[All Projects] Survey designpublic2018-05-22 15:05
Reportertpartner Assigned Todominikvitt  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version3.5.x 
Target Version3.5.xFixed in Version3.7.x 
Summary13521: Access question and survey variables/data from within custom question theme Twig files
Description

Hi Louis, some time ago on IRC you mentioned that you could implement the ability to access all of the values of the aData array in Twig files with {{ dump(aData) }}. I would find it helpful for development to be able to see what is available in that array. Is it still possible to implement that?

Additionally, is it possible to access higher level survey information like language, ID, etc.? (something like EM placeholders)

Thanks.

TagsNo tags attached.
Complete LimeSurvey version number (& build)3.5.1
I will donate to the project if issue is resolvedNo
BrowserN/A
Database & DB-Versionmysqlnd 5.0.12-dev
Server OS (if known)Windows 10
Webserver software & version (if known)Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.9
PHP Version7.1.9

Activities

LouisGac

LouisGac

2018-05-15 15:55

manager   ~47593

(15:53:13) tpartner: [14:58] <tpartner> 2) Is there documentation on what twig vars are available in the custom question theme files? For example, in browserdetect, I see {{name}}, {{basename}}, etc. but don't know what else is available? (I don't see any reference to an array of vars that can be dumped like in the survey theme files)
(15:53:13) tpartner: [15:00] <LouisGac> so just for you to understand the workflow first
(15:53:13) tpartner: [15:00] <LouisGac> now in qanda helper:https://github.com/LimeSurvey/LimeSurvey/blob/master/application/helpers/qanda_helper.php#L5740
(15:53:13) tpartner: [15:00] <LouisGac> that renders any question
(15:53:15) tpartner: [15:01] <LouisGac> the function is here:https://github.com/LimeSurvey/LimeSurvey/blob/master/application/core/LSETwigViewRenderer.php#L84
(15:53:18) tpartner: [15:01] <LouisGac> it checks if this question type has been twigged or not, if not it's just rendering the view like in >2.70, so all the variables are inside $aData
(15:53:21) tpartner: [15:04] <LouisGac> so if you want to knows what are the variables available in the view, you could just var_dump $aData
(15:53:24) tpartner: [15:04] <LouisGac> else, in the original question views, I've documented the used vars
(15:53:26) tpartner: [15:06] <tpartner> Can I dump $aData from within a twig file?
(15:53:28) tpartner: [15:07] <LouisGac> tpartner: not for now, I could add it for debug mode.
(15:53:30) tpartner: [15:08] <tpartner> Thanks, that would be great.

guest

guest

2018-05-17 14:52

viewer   ~47664

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=27170

dominikvitt

dominikvitt

2018-05-17 15:59

developer   ~47665

aData and surveyInfo variables are accessible from question type twig files

Related Changesets

LimeSurvey: master ec2d45c7

2018-05-17 14:52:34

Dominik Vitt

Details Diff
Fixed issue 13521: Access question and survey variables/data from within custom question theme Twig files Affected Issues
13521
mod - application/core/LSETwigViewRenderer.php Diff File

Issue History

Date Modified Username Field Change
2018-03-22 12:19 tpartner New Issue
2018-03-22 12:19 tpartner Status new => assigned
2018-03-22 12:19 tpartner Assigned To => LouisGac
2018-05-15 15:55 LouisGac Note Added: 47593
2018-05-15 15:56 LouisGac Assigned To LouisGac => dominikvitt
2018-05-17 14:52 Changeset attached => LimeSurvey master ec2d45c7
2018-05-17 14:52 guest Note Added: 47664
2018-05-17 14:52 guest Resolution open => fixed
2018-05-17 15:59 dominikvitt Status assigned => resolved
2018-05-17 15:59 dominikvitt Note Added: 47665
2018-05-22 15:05 ollehar Status resolved => closed
2018-05-22 15:05 ollehar Fixed in Version => 3.7.x