|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
DiLDoG Smarty Rookie
Joined: 24 Aug 2003 Posts: 5
|
Posted: Sun Aug 24, 2003 1:10 pm Post subject: add extra newline on every new file |
|
|
How do I make smarty add a newline after every template I display? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Aug 24, 2003 10:23 pm Post subject: |
|
|
Hi.
You can register a postfilter that simply adds an extra linefeed. |
|
Back to top |
|
DiLDoG Smarty Rookie
Joined: 24 Aug 2003 Posts: 5
|
Posted: Sun Aug 24, 2003 10:36 pm Post subject: |
|
|
hmm... tried that one already, but nothing happened
[php:1:ffb0071311]<?php
require("./smarty/Smarty.class.php");
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->caching = false;
$smarty->template_dir = './templates/';
$smarty->compile_dir = './smarty/templates_c/';
$smarty->register_postfilter("add_header_comment");
$smarty->display("header.tpl");
function add_header_comment($tpl_source, &$smarty)
{
return "<!-- Created by Smarty! -->".$tpl_source;
}
?>[/php:1:ffb0071311]
and an other question: is it possible to display the current template file name there, so for example <!-- header.tlp begins here --> |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Aug 24, 2003 10:47 pm Post subject: |
|
|
Well, you still need to embed the newline in the output. Do you want a newline char or a html <br/>? Or both?
[php:1:ee39b52e9e] return "<!-- Created by Smarty! -->".$tpl_source."<br/>\n";[/php:1:ee39b52e9e]It occurs to me that there is a way to get the current template name, but it escapes me at the moment. If I find it, I'll post back but messju probably knows off the top of his head
This of course affects every processed template--I wasn't quite sure if that was what you meant.
Last edited by boots on Mon Aug 25, 2003 7:51 am; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Aug 25, 2003 6:27 am Post subject: |
|
|
boots wrote: | It occurs to me that there is a way to get the current template name, but it escapes me at the moment. If I find it, I'll post back but messju probably knows off the top of his head |
OTOH it's {$smarty.template} . |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|