Welcome to the LimeSurvey Community Forum

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

Which .twig can be loaded in QuestionThemes

  • mrleugim33
  • mrleugim33's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 months ago - 4 years 4 months ago #190844 by mrleugim33
Hello everyone,
Im implementing my own question theme in which I want to put the "question_text_content.twig" and the custom .js and .css.
The problem that I'm facing is that even though the .css loads correctly, the .js doesn't appear when previewing the question and the html from the "question_text_content.twig" is not loaded. I have the same tree structure as in the Bootstrap button Question theme (I based mine over it)
Code:
├── bootstrap_buttons
│   └── survey
│       └── questions
│           └── answer
│               └── shortfreetext
│                   ├── answer.twig
│                   ├── assets
│                   │   ├── bootstrap_buttons_listradio.png
│                   │   └── scripts
│                   │       ├── bootstrapbuttons.css
│                   │       └── bootstrapbuttons.js
│                   ├── columns
│                   │   ├── column_footer.twig
│                   │   └── column_header.twig
│                   ├── config.xml
│                   ├── question_text_content.twig
│                   └── rows
│                       ├── answer_row_noanswer.twig
│                       ├── answer_row_other.twig
│                       └── answer_row.twig

And the config file is as follows:


<?xml version="1.0" encoding="UTF-8"?>
<!--
Default configuration for the listradio question template.
-->

<config>
<!-- Those metadata will be displayed in the template configuration page. They are not used for now. -->
<metadata>
<name>bootstrap_buttons</name>
<title>Bootstrap Buttons</title>
<creationDate>22/05/2018</creationDate>
<author>Dominik Vitt</author>
<authorEmail>dominik.vitt@limesurvey.org
<authorUrl> www.limesurvey.org
<copyright>Copyright (C) 2005 - 2018 LimeSurvey Gmbh, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later</license>
<version>1.0</version>
<apiVersion>1</apiVersion>
<description>New implementation of the Bootstrap buttons question theme</description>
</metadata>

<!--
Here the list of the css/js files to load.
Any file here will be loaded via the asset manager (when in config.php debug = 0)
-->
<files>
<css>
<filename>scripts/bootstrapbuttons.css</filename>
</css>
<js>
<filename>scripts/bootstrapbuttons.js</filename>
</js>
<preview>
<filename>bootstrap_buttons_listradio.png</filename>
</preview>
</files>

<custom_attributes>
<attribute>
<name>button_size</name>
<category>Display theme options</category>
<sortorder>90</sortorder>
<inputtype>buttongroup</inputtype>
<options>
<default>Default</default>
<lg>Large</lg>
<sm>Small</sm>
<xs>Extra small</xs>
</options>
<default>default</default>
<help>Change button size</help>
<caption>Button size</caption>
<i18n>hr</i18n>
</attribute>
<attribute>
<name>max_buttons_row</name>
<category>Display theme options</category>
<sortorder>91</sortorder>
<inputtype>buttongroup</inputtype>
<options>
<default>Default</default>
<col-sm-12>1</col-sm-12>
<col-sm-6>2</col-sm-6>
<col-sm-4>3</col-sm-4>
<col-sm-3>4</col-sm-3>
<col-sm-2>6</col-sm-2>
<col-sm-1>12</col-sm-1>
</options>
<default></default>
<help>Choose maximum number of buttons in a row</help>
<caption>Maximum number of buttons in a row</caption>
</attribute>
<!-- hidden attributes -->
<attribute>
<name>display_columns</name>
<inputtype></inputtype>
<help>hide display_columns</help>
<caption>hide display_columns</caption>
</attribute>
<attribute>
<name>input_size</name>
<inputtype></inputtype>
<help>hide input_size</help>
<caption>hide input_size</caption>
</attribute>
</custom_attributes>

<!-- Here datas about how LimeSurvey should load the core js/css of the question -->
<engine>
<load_core_css>true</load_core_css>
<load_core_js>true</load_core_js>
<show_as_template>true</show_as_template>
<show_as_question_type>true</show_as_question_type>
</engine>
</config>


Is there any problem in the config or the folder structure that I'm missing??

(If it helps, I've checked that the temporary files are correct, but they are not, even after deleting them they still have the original code).

Thank you very much for any help ^^
Last edit: 4 years 4 months ago by mrleugim33.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago #190854 by tpartner
Replied by tpartner on topic Which .twig can be loaded in QuestionThemes
I'm not sure why the JS is not loaded but you will need to reference the custom Twig file from within an existing Twig file.

Code:
{% include './survey/questions/answer/shortfreetext/question_text_content.twig' %}

Have a look at the structure and manifest of this custom theme which loads a CSS file, a JS file and a custom Twig file - github.com/tpartner/LimeSurvey-Multiple-Choice-Dropdown .

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose