Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: Adding new pstpl template file.

Adding new pstpl template file. 2 Jahre 10 Monate her #70392

  • mwilliams
  • mwilliamss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
Hello,

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.
Letzte Änderung: 2 Jahre 10 Monate her von mwilliams.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70410

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5331
  • Dank erhalten: 296
  • Karma: 249
There is a function which puts together the different pstpl files of the template. There is also a "templatereplace()" function to replace placeholders within templates.

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)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70428

  • mwilliams
  • mwilliamss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
So the line to call the new .pstpl file in an existing file is "templatereplace({newfile.pstpl})"? I'm guessing that's wrong.

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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70429

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5331
  • Dank erhalten: 296
  • Karma: 249
mwilliams schrieb:
So the line to call the new .pstpl file in an existing file is "templatereplace({newfile.pstpl})"? I'm guessing that's wrong.
You are right ... because I didn't say it this way :-)

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)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70430

  • mwilliams
  • mwilliamss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
Yep, that was a complete guess on my part!

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).
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70434

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4270
  • Dank erhalten: 804
  • Karma: 368
I would also recommend using an AJAX call to pull in the remote menu file. This would avoid hacking the core code.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70467

  • mwilliams
  • mwilliamss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
Not sure about the AJAX solution as I'm not familiar with it. I've instead written a solution for sed. It's a kludge and will break if I modify startpage.pstpl above a critical line but it works.

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.
Letzte Änderung: 2 Jahre 10 Monate her von mwilliams.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 2 Jahre 10 Monate her #70470

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4270
  • Dank erhalten: 804
  • Karma: 368
Here's an example of using AJAX to access the remote file.

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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 1 Jahr 4 Monate her #96924

  • joss
  • josss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
I'm running 2 surveys and I'd like to have different banners each when entering to the survey.
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>
and I changed my pstl file with your code above.
The problem is that even when I enter the surveys I get the "default" echo.
What is wrong?

Thanks for your support
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Adding new pstpl template file. 1 Jahr 4 Monate her #96925

  • joss
  • josss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 16
  • Karma: 0
So, I understand that using Ajax, firstly the php loads into html and secondly it is embedded in the pstl file.

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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.200 Sekunden
Donation Image