【转】Smarty模板中编写js的时候使用literal

{literal}

<script type="text/javascript">

function exportStudent(){

document.all.sear.is_export.value = "true";
document.all.sear.submit();
}
</script>
{/literal}


//------保留变量-------

{$smarty} reserved variable

The reserved {$smarty} variable can be used to access several special template variables. The full list of them follows.

Request variables

The request variables such as get, post, cookies, server, environment, and session variables can be accessed as demonstrated in the examples below:

Example 4-6. displaying request variables

{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}

{* display the variable "page" from a form (POST) *}
{$smarty.post.page}

{* display the value of the cookie "username" *}
{$smarty.cookies.username}

{* display the server variable "SERVER_NAME" *}
{$smarty.server.SERVER_NAME}

{* display the system environment variable "PATH" *}
{$smarty.env.PATH}

{* display the php session variable "id" *}
{$smarty.session.id}

{* display the variable "username" from merged get/post/cookies/server/env *}
{$smarty.request.username}

Note: For historical reasons {$SCRIPT_NAME} can be accessed directly though {$smarty.server.SCRIPT_NAME} is the proposed way to access this value.

{$smarty.now}

The current timestamp can be accessed with {$smarty.now}. The number reflects the number of seconds passed since the so-called Epoch (January 1, 1970) and can be passed directly to date_format modifier for display purposes.

Example 4-7. using {$smarty.now}

{* use the date_format modifier to show current date and time *}
{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}{$smarty.const}

You can access PHP constant values directly.

Example 4-8. using {$smarty.const}

{$smarty.const._MY_CONST_VAL}{$smarty.capture}

The output captured via {capture}..{/capture} construct can be accessed using {$smarty} variable. See section on capture for an example.

{$smarty.config}

{$smarty} variable can be used to refer to loaded config variables. {$smarty.config.foo} is a synonym for {#foo#}. See the section on config_load for an example.

{$smarty.section}, {$smarty.foreach}

{$smarty} variable can be used to refer to 'section' and 'foreach' loop properties. See docs for section and foreach.

{$smarty.template}

This variable contains the name of the current template being processed.

{$smarty.version}

This variable contains the version of Smarty the template was compiled with.

{$smarty.ldelim}

This variable is used for printing the left-delimiter value literally. See also {ldelim},{rdelim}.

{$smarty.rdelim}

This variable is used for printing the right-delimiter value literally. See also {ldelim},{rdelim}.

posted @ 2015-05-21 10:31  1317660800  阅读(256)  评论(0编辑  收藏  举报