Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>WAP/WML</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="Tips & Tricks"
HREF="tips.html"><LINK
REL="PREVIOUS"
TITLE="Dates"
HREF="tips.dates.html"><LINK
REL="NEXT"
TITLE="Componentized Templates"
HREF="tips.componentized.templates.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="tips.dates.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 18. Tips &#38; Tricks</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="tips.componentized.templates.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="tips.wap"
></A
>WAP/WML</H1
><P
>&#13;    WAP/WML templates require a php
    <A
HREF="http://php.net/header"
TARGET="_top"
>Content-Type header</A
>
    to be passed along
    with the template. The easist way to do this would be to write a custom
    function that prints the header. If you are using
    <A
HREF="caching.html"
>caching</A
>, that won't
    work so we'll do it using the
    <A
HREF="language.function.insert.html"
><TT
CLASS="varname"
>{insert}</TT
></A
>
    tag; remember <TT
CLASS="varname"
>{insert}</TT
> tags are not
    cached! Be sure that there is nothing output to the browser before the
    template, or else the header may fail.
   </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN7677"
></A
><P
><B
>Example 18-6. Using {insert} to write a WML Content-Type header</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;be&nbsp;sure&nbsp;apache&nbsp;is&nbsp;configure&nbsp;for&nbsp;the&nbsp;.wml&nbsp;extensions!<br />//&nbsp;put&nbsp;this&nbsp;function&nbsp;somewhere&nbsp;in&nbsp;your&nbsp;application,&nbsp;or&nbsp;in&nbsp;Smarty.addons.php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">insert_header</span><span style="color: #007700">(</span><span style="color: #0000BB">$params</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;function&nbsp;expects&nbsp;$content&nbsp;argument<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(empty(</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #DD0000">'content'</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #DD0000">'content'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;return;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></TD
></TR
></TABLE
><P
>&#13;     your Smarty template <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>must</I
></SPAN
> begin with the insert tag :
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>{insert name=header content="Content-Type: text/vnd.wap.wml"}

&#60;?xml version="1.0"?&#62;
&#60;!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"&#62;

&#60;!-- begin new wml deck --&#62;
&#60;wml&#62;
 &#60;!-- begin first card --&#62;
 &#60;card&#62;
  &#60;do type="accept"&#62;
   &#60;go href="#two"/&#62;
  &#60;/do&#62;
  &#60;p&#62;
   Welcome to WAP with Smarty!
   Press OK to continue...
  &#60;/p&#62;
 &#60;/card&#62;
 &#60;!-- begin second card --&#62;
 &#60;card id="two"&#62;
  &#60;p&#62;
   Pretty easy isn't it?
  &#60;/p&#62;
 &#60;/card&#62;
&#60;/wml&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></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="tips.dates.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="tips.componentized.templates.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Dates</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="tips.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Componentized Templates</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>