- Posts: 11
- Thank you received: 0
Adding new pstpl template file.
How can I add a new .pstpl template file to a theme? I'll skip the background information, suffice to say it's necessary.
I'm looking to:
1) Create the .pstpl file and place it in the new theme directory (can do that easily).
2) Insert/call the new .pstpl file at a particular line in startpage.pstpl (I'm having difficulty doing this).
Any ideas other than suggesting not doing it? I don't mind core hacks but would obviously prefer other methods if possible.
Thanks,
Mark.
Please Log in or Create an account to join the conversation.
I do not recommend to hack the core though. You will have problems when updating later on and other templates might get broken.
Better embedd your changes at some of the existing files since it is probably just some HTML?!?
Maybe you can outline in more detail why you want to do these changes?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Please Log in or Create an account to join the conversation.
I'm essentially looking for an equivalent to <?php include("newfile.php"); ?> for example.
In brief terms, Limesurvey is running in a custom theme with a particular menu. To keep the menus in sync with other areas of the site after updates, I've written a Bash shell script which screenscrapes the default menu and replaces specified menu files. I'd like to create menu.pstpl which can be automatically replaced by that script when required.
Please Log in or Create an account to join the conversation.
You are right ... because I didn't say it this waymwilliams wrote: So the line to call the new .pstpl file in an existing file is "templatereplace({newfile.pstpl})"? I'm guessing that's wrong.

Why not editing the startpage.pstpl file instead?
You won't be able to call a PHP script inside the template directly but you could use an Ajax call for that.
Another solution might be to simply embedd Limesurvey in an iframe.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Please Log in or Create an account to join the conversation.
Will templatereplace() or another function work in the same way as the PHP example? I know the PHP call won't work but that's the type of thing I'm hoping to do. The menu file contains simple HTML so can be any file format (.pstpl, .htm, .php, etc).
Please Log in or Create an account to join the conversation.
- Posts: 6738
- Karma: 601
- Thank you received: 1807
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in or Create an account to join the conversation.
It'd be handy to simply call other template files though. I presumed it would be possible as it's fairly straightforward in other CMS. Do you think it's worthwhile creating a feature request?
Thanks for the help.
Please Log in or Create an account to join the conversation.
- Posts: 6738
- Karma: 601
- Thank you received: 1807
Let's say your remote menu file is called menuTest.php and lives in your template folder.
Insert the following script into any element in your .pstpl files (say a <div id="menuWrapper">).
It will pull in the contents of menuTest.php and append them to the inner HTML of the element that contains the script (#menuWrapper in this case).
<script type="text/javascript" charset="utf-8">
// Identify the current script element NOTE: must be before $(document).ready(function()
var scripts = document.getElementsByTagName('script');
var thisScript = scripts[scripts.length - 1];
$(document).ready(function() {
// Identify the current script's parent element
var scriptParent = $(thisScript).parent();
// Pull in the remote file
$.ajax({
url: '{TEMPLATEURL}menuTest.php',
dataType: 'html',
success: function(results){
// Load the remote file contents into the script parent element
$(scriptParent).append(results);
}
});
});
</script>
If you want to completely overwrite the inner HTML, change this:
$(scriptParent).append(results);
To this:
$(scriptParent).html(results);
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in or Create an account to join the conversation.
Therefore I made a banner.php file to include into the startpage.pstl file.
My banner.php is
<a href="my-link" target="_blank" title="my title" id="link-logo">
<?php
if ($_GET["sid"]=="28836")
echo "image for survey 1";
else if ($_GET["sid"]=="69731")
echo "image for survey 2";
else
echo "default";
?>
</a>
The problem is that even when I enter the surveys I get the "default" echo.
What is wrong?
Thanks for your support
Please Log in or Create an account to join the conversation.
The correct question is: How can I pass the get value of the survey id to the Ajax function that prepares banner.php?
Maybe it's a quick solution but when it comes to javascript I'm a real novice
Thanks
Please Log in or Create an account to join the conversation.
- Posts: 6738
- Karma: 601
- Thank you received: 1807
Place the two banner graphics in your template directory and name them something like banner-28836.png and banner-69731.png.
Then you should be able to use something like this in startpage.pstpl:
<img class="banner" src="{TEMPLATEURL}banner-{SID}.png" />
If you need a default banner, you can use jQuery to modify the src attribute of the image tag.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in or Create an account to join the conversation.
The default banner in the example is banner-.png which is again working.
Please Log in or Create an account to join the conversation.
- Posts: 6738
- Karma: 601
- Thank you received: 1807
Even easier than JavaScriptThe default banner in the example is banner-.png which is again working.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in or Create an account to join the conversation.