- Posts: 20
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can I use PHP code in the template editor?
- Magnar
- Topic Author
- Offline
- Junior Member
Less
More
7 years 1 month ago - 7 years 1 month ago #150025
by Magnar
Can I use PHP code in the template editor? was created by Magnar
Hello everyone,
here's my situation: I want to create a template with a logo in the navigation. This logo is being uploaded through the template editor as usual and always has the same file name. However, the filename extension can be either .svg, .png or .jpg.
I want to solve this by using the PHP function file_exists but can't seem to get it to work in the template editor. It seems PHP code is automatically being removed or changed in there. Is there some other way to use PHP in there or, alternatively, disable the code correction?
here's my situation: I want to create a template with a logo in the navigation. This logo is being uploaded through the template editor as usual and always has the same file name. However, the filename extension can be either .svg, .png or .jpg.
I want to solve this by using the PHP function file_exists but can't seem to get it to work in the template editor. It seems PHP code is automatically being removed or changed in there. Is there some other way to use PHP in there or, alternatively, disable the code correction?
Last edit: 7 years 1 month ago by Magnar.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
7 years 1 month ago #150027
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Can I use PHP code in the template editor?
As far as I know, you can't use PHP in Limesurvey templates. You can use Javascript though.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
7 years 1 month ago - 7 years 1 month ago #150057
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Can I use PHP code in the template editor?
Why isn't it possible to control suffix of the file? Seems quite unusual since you need to modify the template in a manual way.
PHP is not working. JavaScript in form of AJAX (since you want to check something on the server side) or EM variables (if it is good enough to assign the correct suffix via a hidden variable in the survey-file).
Get some inspiration from this old thread:
www.limesurvey.org/forum/design-issues/7...-pstpl-template-file
AJAX via jQuery:
api.jquery.com/jquery.ajax/
PHP is not working. JavaScript in form of AJAX (since you want to check something on the server side) or EM variables (if it is good enough to assign the correct suffix via a hidden variable in the survey-file).
Get some inspiration from this old thread:
www.limesurvey.org/forum/design-issues/7...-pstpl-template-file
AJAX via jQuery:
api.jquery.com/jquery.ajax/
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Last edit: 7 years 1 month ago by jelo.
The topic has been locked.