Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 8377d4bb25a3992aad680df2952f4b71 > files > 83

php-smarty-doc-2.6.26-1mdv2010.0.noarch.rpm

<HTML
><HEAD
><TITLE
>{insert}</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Smarty Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Built-in Functions"
HREF="language.builtin.functions.html"><LINK
REL="PREVIOUS"
TITLE="{include_php}"
HREF="language.function.include.php.html"><LINK
REL="NEXT"
TITLE="{ldelim},{rdelim}"
HREF="language.function.ldelim.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Smarty Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="language.function.include.php.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 7. Built-in Functions</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.function.ldelim.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.function.insert"
></A
>{insert}</H1
><P
>&#13;   <TT
CLASS="varname"
>{insert}</TT
> tags work much like <A
HREF="language.function.include.html"
><TT
CLASS="varname"
>{include}</TT
></A
> tags,
   except that <TT
CLASS="varname"
>{insert}</TT
> tags are NOT cached when
   template <A
HREF="caching.html"
>caching</A
> is enabled. They
   will be executed on every invocation of the template.
 </P
><DIV
CLASS="informaltable"
><A
NAME="AEN2158"
></A
><P
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Attribute Name</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Type</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Required</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Default</TH
><TH
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>name</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>string</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Yes</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The name of the insert function (insert_name)</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>assign</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>string</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The name of the template variable the output will
      be assigned to</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>script</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>string</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The name of the php script that is included before
      the insert function is called</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>[var ...]</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>[var type]</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>variable to pass to insert function</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
><P
>&#13;  Let's say you have a template with a banner slot at the top of
  the page. The banner can contain any mixture of HTML, images,
  flash, etc. so we can't just use a static link here, and we
  don't want this contents cached with the page. In comes the
  {insert} tag: the template knows #banner_location_id# and
  #site_id# values (gathered from a
  <A
HREF="config.files.html"
>config file</A
>), and needs to
  call a function to get the banner contents.
 </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2203"
></A
><P
><B
>Example 7-22. function {insert}</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>{* example of fetching a banner *}
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;  In this example, we are using the name <SPAN
CLASS="QUOTE"
>"getBanner"</SPAN
> and passing the
  parameters #banner_location_id# and #site_id#. Smarty will look
  for a function named insert_getBanner() in your PHP application, passing
  the values of #banner_location_id# and #site_id# as the first argument
  in an associative array. All {insert} function names in
  your application must be prepended with "insert_" to remedy possible
  function name-space conflicts. Your insert_getBanner() function should
  do something with the passed values and return the results. These results
  are then displayed in the template in place of the {insert} tag.
  In this example, Smarty would call this function:
  insert_getBanner(array("lid" =&#62; "12345","sid" =&#62; "67890"));
   and display the returned results in place of the {insert} tag.
  </P
><P
></P
><UL
><LI
><P
>&#13;   If you supply the <TT
CLASS="parameter"
><I
>assign</I
></TT
> attribute,
   the output of the <TT
CLASS="varname"
>{insert}</TT
> tag
   will be assigned to this template variable instead of being output
   to the template.
   <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
    Assigning the output to a template variable isn't too useful with
   <A
HREF="variable.caching.html"
>caching</A
> enabled.
   </P
></BLOCKQUOTE
></DIV
>
  </P
></LI
><LI
><P
>&#13;   If you supply the <TT
CLASS="parameter"
><I
>script</I
></TT
> attribute,
   this php script will be
   included (only once) before the <TT
CLASS="varname"
>{insert}</TT
> function is executed. This
   is the case where the insert function may not exist yet, and a php
   script must be included first to make it work.
   </P
><P
>&#13;   The path can be
   either absolute, or relative to
   <A
HREF="variable.trusted.dir.html"
><TT
CLASS="parameter"
><I
>$trusted_dir</I
></TT
></A
>. When <A
HREF="variable.security.html"
><TT
CLASS="parameter"
><I
>$security</I
></TT
></A
> is enabled, the script
   must reside in <A
HREF="variable.trusted.dir.html"
><TT
CLASS="parameter"
><I
>$trusted_dir</I
></TT
></A
>.
  </P
></LI
></UL
><P
>&#13;   The Smarty object is passed as the second argument. This way you
   can reference and modify information in the Smarty object from
   within the <TT
CLASS="varname"
>{insert}</TT
> function.
  </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Technical Note: </B
>
    It is possible to have portions of the template not
    cached. If you have <A
HREF="caching.html"
>caching</A
>
    turned on, <TT
CLASS="varname"
>{insert}</TT
> tags will not be cached. They will run
    dynamically every time the page is created, even within cached
    pages. This works good for things like banners, polls, live
    weather, search results, user feedback areas, etc.
   </P
></BLOCKQUOTE
></DIV
><P
>&#13;    See also
  <A
HREF="language.function.include.html"
><TT
CLASS="varname"
>{include}</TT
></A
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="language.function.include.php.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="language.function.ldelim.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>{include_php}</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.builtin.functions.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>{ldelim},{rdelim}</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>