Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>Cache Groups</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="Caching"
HREF="caching.html"><LINK
REL="PREVIOUS"
TITLE="Multiple Caches Per Page"
HREF="caching.multiple.caches.html"><LINK
REL="NEXT"
TITLE="Controlling Cacheability of Plugins' Output"
HREF="caching.cacheable.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="caching.multiple.caches.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 14. Caching</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="caching.cacheable.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="caching.groups"
></A
>Cache Groups</H1
><P
>&#13;      You can do more elaborate grouping by setting up
      <TT
CLASS="parameter"
><I
>$cache_id</I
></TT
> groups. This is
      accomplished by separating each sub-group with a vertical bar
      <TT
CLASS="literal"
>|</TT
> in the <TT
CLASS="parameter"
><I
>$cache_id</I
></TT
> value.
      You can have as many sub-groups as you like.
     </P
><P
></P
><UL
><LI
><P
>&#13;      You can think of cache groups like a directory hierarchy. For instance, a
      cache group of <TT
CLASS="literal"
>'a|b|c'</TT
> could be thought of as the
      directory structure <TT
CLASS="literal"
>'/a/b/c/'</TT
>.
      </P
></LI
><LI
><P
>&#13;      <TT
CLASS="literal"
>clear_cache(null,'a|b|c')</TT
>
      would be like removing the files
      <TT
CLASS="literal"
>'/a/b/c/*'</TT
>. <TT
CLASS="literal"
>clear_cache(null,'a|b')</TT
>
      would be like removing the files <TT
CLASS="literal"
>'/a/b/*'</TT
>.
      </P
></LI
><LI
><P
>&#13;      If you specify a
      <A
HREF="variable.compile.id.html"
><TT
CLASS="parameter"
><I
>$compile_id</I
></TT
></A
>
      such as <TT
CLASS="literal"
>clear_cache(null,'a|b','foo')</TT
> it is treated as
      an appended cache group <TT
CLASS="literal"
>'/a/b/c/foo/'</TT
>.
      </P
></LI
><LI
><P
>&#13;      If you specify a template name such as
      <TT
CLASS="literal"
>clear_cache('foo.tpl','a|b|c')</TT
> then Smarty will attempt
      to remove <TT
CLASS="literal"
>'/a/b/c/foo.tpl'</TT
>.
      </P
></LI
><LI
><P
>&#13;      You CANNOT remove a specified template name under
      multiple cache groups such as <TT
CLASS="literal"
>'/a/b/*/foo.tpl'</TT
>, the
      cache grouping works
      left-to-right ONLY. You will need to group your templates under a single
      cache group heirarchy to be able to clear them as a group.
     </P
></LI
></UL
><P
>&#13;      Cache grouping should not be confused with your template directory
      heirarchy, the cache grouping has no knowledge of how your templates are
      structured. So for example, if you have a template structure like
      <TT
CLASS="filename"
>themes/blue/index.tpl</TT
> and you want to be able to
      clear all the cache files for the <SPAN
CLASS="QUOTE"
>"blue"</SPAN
> theme, you will need
      to create a cache group
      structure that mimics your template file structure, such as
      <TT
CLASS="literal"
>display('themes/blue/index.tpl','themes|blue')</TT
>, then
      clear them with
      <TT
CLASS="literal"
>clear_cache(null,'themes|blue')</TT
>.
     </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN6829"
></A
><P
><B
>Example 14-9. $cache_id groups</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">'Smarty.class.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$smarty&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Smarty</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">caching&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;clear&nbsp;all&nbsp;caches&nbsp;with&nbsp;'sports|basketball'&nbsp;as&nbsp;the&nbsp;first&nbsp;two&nbsp;cache_id&nbsp;groups<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">clear_cache</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,</span><span style="color: #DD0000">'sports|basketball'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;clear&nbsp;all&nbsp;caches&nbsp;with&nbsp;"sports"&nbsp;as&nbsp;the&nbsp;first&nbsp;cache_id&nbsp;group.&nbsp;This&nbsp;would<br />//&nbsp;include&nbsp;"sports|basketball",&nbsp;or&nbsp;"sports|(anything)|(anything)|(anything)|..."<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">clear_cache</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,</span><span style="color: #DD0000">'sports'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;clear&nbsp;the&nbsp;foo.tpl&nbsp;cache&nbsp;file&nbsp;with&nbsp;"sports|basketball"&nbsp;as&nbsp;the&nbsp;cache_id<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">clear_cache</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo.tpl'</span><span style="color: #007700">,</span><span style="color: #DD0000">'sports|basketball'</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'index.tpl'</span><span style="color: #007700">,</span><span style="color: #DD0000">'sports|basketball'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></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="caching.multiple.caches.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="caching.cacheable.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Multiple Caches Per Page</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="caching.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Controlling Cacheability of Plugins' Output</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>