mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
moved version variable to internal variable
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
||||
- move $version to internal variable, remove from docs (Monte)
|
||||
- cleaned up compiled templates global scope by moving some variables into
|
||||
the class itself. (Andrei)
|
||||
- fixed a bug that would not allow referring to a section in the including
|
||||
|
@@ -130,7 +130,6 @@ class Smarty
|
||||
'count_paragraphs' => 'smarty_mod_count_paragraphs'
|
||||
);
|
||||
|
||||
var $version = '1.4.1'; // Smarty version number
|
||||
var $show_info_header = false; // display HTML info header at top of page output
|
||||
|
||||
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
||||
@@ -150,6 +149,7 @@ class Smarty
|
||||
var $_sections = array(); // keeps track of sections
|
||||
var $_conf_obj = null; // configuration object
|
||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||
var $_version = '1.4.1'; // Smarty version number
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
|
@@ -145,7 +145,7 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
// put header at the top of the compiled template
|
||||
$template_header = "<?php /* Smarty version ".$this->version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||
$template_header = "<?php /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||
$template_header .= " compiled from ".$tpl_file." */ ?>\n";
|
||||
$template_compiled = $template_header.$template_compiled;
|
||||
|
||||
|
95
docs.sgml
95
docs.sgml
@@ -14,7 +14,7 @@
|
||||
<address><email>andrei@php.net</email></address>
|
||||
</affiliation>
|
||||
</author>
|
||||
<edition>Version 1.3.0</edition>
|
||||
<edition>Version 1.4.1</edition>
|
||||
<copyright><year>2001</year><holder>ispi of Lincoln, Inc.</holder></copyright>
|
||||
</bookinfo>
|
||||
<chapter>
|
||||
@@ -468,12 +468,6 @@ chmod 700 cache
|
||||
Smarty.addons.php.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="setting.version">
|
||||
<title>$version</title>
|
||||
<para>
|
||||
Current version of Smarty, used in info header.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="setting.show.info.header">
|
||||
<title>$show_info_header</title>
|
||||
<para>
|
||||
@@ -4155,6 +4149,93 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
|
||||
<title>Tips & Tricks</title>
|
||||
<para>
|
||||
</para>
|
||||
<sect1>
|
||||
<title>Blank Variable Handling</title>
|
||||
<para>
|
||||
There may be times when you want to print a default value for an empty
|
||||
variable instead of printing nothing, such as printing "&nbsp;" so that
|
||||
table backgrounds work properly. Many would use an {if} statement to
|
||||
handle this, but there is a shorthand way with Smarty, using the
|
||||
<emphasis>default</emphasis> variable modifier.
|
||||
</para>
|
||||
<example>
|
||||
<title>Printing &nbsp; when a variable is empty</title>
|
||||
<programlisting>
|
||||
|
||||
|
||||
{* the long way *}
|
||||
|
||||
{if $title eq ""}
|
||||
&nbsp;
|
||||
{else}
|
||||
{$title}
|
||||
{/if}
|
||||
|
||||
|
||||
{* the short way *}
|
||||
|
||||
{$title|default:"&nbsp;"}
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>Passing variable title to header template</title>
|
||||
<para>
|
||||
When the majority of your templates use the same headers and footers, it
|
||||
is common to split those out into their own templates and include them.
|
||||
But what if the header needs to have a different title, depending on
|
||||
what page you are coming from? You can pass the title to the header when
|
||||
it is included.
|
||||
</para>
|
||||
<example>
|
||||
<title>Passing the title variable to the header template</title>
|
||||
<programlisting>
|
||||
|
||||
|
||||
mainpage.tpl
|
||||
------------
|
||||
|
||||
{include file="header.tpl" title="Main Page"}
|
||||
{* template body goes here *}
|
||||
{include file="footer.tpl"}
|
||||
|
||||
|
||||
archives.tpl
|
||||
------------
|
||||
|
||||
{config_load file="archive_page.conf"}
|
||||
{include file="header.tpl" title=#archivePageTitle#}
|
||||
{* template body goes here *}
|
||||
{include file="footer.tpl"}
|
||||
|
||||
|
||||
header.tpl
|
||||
----------
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>{$title|default:"BC News"}</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
|
||||
footer.tpl
|
||||
----------
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
When the main page is drawn, the title of "Main Page" is passed to the
|
||||
header.tpl, and will subsequently be used as the title. When the
|
||||
archives page is drawn, the title will be "Archives". Notice in the
|
||||
archive example, we are using a varible from the archives_page.conf
|
||||
file instead of a hard coded variable. Also notice that "BC News" is
|
||||
printed if the $title variable is not set, using the
|
||||
<emphasis>default</emphasis> variable modifier.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>Dates</title>
|
||||
<para>
|
||||
|
@@ -130,7 +130,6 @@ class Smarty
|
||||
'count_paragraphs' => 'smarty_mod_count_paragraphs'
|
||||
);
|
||||
|
||||
var $version = '1.4.1'; // Smarty version number
|
||||
var $show_info_header = false; // display HTML info header at top of page output
|
||||
|
||||
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
||||
@@ -150,6 +149,7 @@ class Smarty
|
||||
var $_sections = array(); // keeps track of sections
|
||||
var $_conf_obj = null; // configuration object
|
||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||
var $_version = '1.4.1'; // Smarty version number
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
|
@@ -145,7 +145,7 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
// put header at the top of the compiled template
|
||||
$template_header = "<?php /* Smarty version ".$this->version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||
$template_header = "<?php /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||
$template_header .= " compiled from ".$tpl_file." */ ?>\n";
|
||||
$template_compiled = $template_header.$template_compiled;
|
||||
|
||||
|
Reference in New Issue
Block a user