View previous topic :: View next topic |
Author |
Message |
phaitour Smarty n00b
Joined: 10 Mar 2008 Posts: 2
|
Posted: Mon Mar 10, 2008 9:31 am Post subject: |
|
|
very helpful guys! Thanks! |
|
Back to top |
|
mattpro Smarty Rookie
Joined: 10 May 2008 Posts: 8
|
Posted: Mon Jun 23, 2008 8:57 am Post subject: Re: Reg Exp to the rescue ! |
|
|
kilimangaro wrote: | Try these prefilters functions, they work perfectly for us:
[php]function smarty_prefilter_literal_script_and_style(&$tpl_source, &$smarty) {
$pattern[] = '~<script\b(?![^>]*smarty)(.*)</script>~siU';
$replace[] = '<!-- {literal} --><script$1 $2</script><!-- {/literal} -->';
$pattern[] = '~<style\b(?![^>]*smarty)>(.*)</style>~siU';
$replace[] = '<!--{literal}--><style$1>$2</style><!--{/literal}-->';
return preg_replace($pattern, $replace, $tpl_source);
}
class MySmarty extends Smarty {
function MySmarty() {
$this->register_prefilter('smarty_prefilter_literal_script_and_style');
}
}[/php]
It brace all <script> and <style> tags whith {litteral} so that
Code: | <script language="JavaScript" type="text/JavaScript">
<!--
function doSomeJS() {
// blabla ...
}
-->
</script> |
... give ...
Code: | <!--{literal}--><script language="JavaScript" type="text/JavaScript">
<!--
function doSomeJS() {
// blabla ...
}
-->
</script><!--{/literal}--> |
... but ...
Code: | <script language="JavaScript" type="text/JavaScript" smarty>
<!--
showMyLayer1 = {$smarty.get.id|intval}
-->
</script> |
... give ...
Code: | <script language="JavaScript" type="text/JavaScript" smarty>
<!--
showMyLayer1 = {$smarty.get.id|intval}
-->
</script> |
Wondefull! isn't? |
Thanks that worked great. |
|
Back to top |
|
student of life Smarty n00b
Joined: 09 Sep 2008 Posts: 3
|
Posted: Tue Sep 09, 2008 7:22 am Post subject: |
|
|
thanks. i'm learning a lot of information here. |
|
Back to top |
|
manfred Smarty Rookie
Joined: 07 Oct 2008 Posts: 10
|
Posted: Tue Nov 18, 2008 6:09 pm Post subject: {include file=style.css} |
|
|
is it possible in smarty?
Now i am usin this code to include style sheet but not working
in .tpl
Code: |
<style>
{literal}
{include file="style.css"}
{/literal}
</style>
<td id="reg" >Username</td>
|
in CSS
Code: |
/* CSS Document */
#reg {
background-color:#0000FF;
font:Verdana, Arial, Helvetica, sans-serif;
width:200px;
}
if it possible please help me
thanks
|
|
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Wed Nov 19, 2008 8:01 am Post subject: |
|
|
Try {fetch} instead of {include}. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
manfred Smarty Rookie
Joined: 07 Oct 2008 Posts: 10
|
Posted: Tue Nov 25, 2008 5:17 pm Post subject: |
|
|
When i use fetch i got this error
Fatal error: Smarty error: [plugin] fetch cannot read file 'style.css' |
|
Back to top |
|
manfred Smarty Rookie
Joined: 07 Oct 2008 Posts: 10
|
Posted: Tue Nov 25, 2008 5:18 pm Post subject: |
|
|
Thank you for the reply |
|
Back to top |
|
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 541
|
Posted: Mon Dec 22, 2008 3:29 pm Post subject: |
|
|
my delimiters are
<{ and }> and I've never run into problems. |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Thu Jan 15, 2009 10:46 am Post subject: Use unobstrusive javascripts |
|
|
Try to write ALL of you java scripts in an external file and use them in an unobtrusive manners. |
|
Back to top |
|
muhammad Smarty Rookie
Joined: 07 May 2009 Posts: 5
|
Posted: Fri May 08, 2009 5:36 am Post subject: Re: How to use Javascript codes in template files? |
|
|
hbilgen wrote: | Hi,
I'm using javascript codes in my template files, but Smarty recognizes function curly braces '{' of functions as variables and gives error.
How to use those javascript function codes in template files? |
Put your javascript code in between {literal}{/literal} |
|
Back to top |
|
jonemere Smarty n00b
Joined: 04 Jan 2010 Posts: 3
|
Posted: Tue Jan 05, 2010 6:32 am Post subject: |
|
|
Thanks for the posting, It is really helpful to me.
Your post is very interesting and I teach something new over here. Nice information.
My heartiest thanks for sharing. _________________ 2.5 hdd |
|
Back to top |
|
mrghost18 Smarty n00b
Joined: 06 May 2010 Posts: 2
|
Posted: Thu May 06, 2010 6:05 am Post subject: |
|
|
Can anyone say how to fetch all datas from a database in smarty and show them in a table? |
|
Back to top |
|
chefkoch666 Smarty n00b
Joined: 15 May 2010 Posts: 2
|
Posted: Sat May 15, 2010 7:22 am Post subject: Thank you |
|
|
Really helpful sticky!
Thanks a lot!
@mrghost18: Please see on the left homepage navigation Get Help! -> Sample Application, especially page 5 and previous. You have to fetch data with php or whatever language you are using and then iterate through the array with foreach.
Best regards,
Marek |
|
Back to top |
|
hazelbates98 Smarty n00b
Joined: 21 Oct 2011 Posts: 1 Location: Sydney, NSW
|
Posted: Fri Oct 21, 2011 8:17 am Post subject: Gratitude |
|
|
Thank you for the wonderful information shared. It is very useful. |
|
Back to top |
|
Juggler Smarty n00b
Joined: 05 Dec 2012 Posts: 1
|
Posted: Wed Dec 05, 2012 10:13 am Post subject: What are the best delimeters then? |
|
|
What are the best delimeters then?
What I've seen
{{ }}
{# #}
<{ }>
Obviously to hide them from html developers/designers and not interfere with javascript? |
|
Back to top |
|
|