Template lite advanced caching needed

Discussion about anything pertaining to Template Lite

Template lite advanced caching needed

Postby markg85 on Tue Sep 04, 2007 1:39 pm

Hey,

i'm currently using ADOdb Lite and Template Lite for my script in the making (MageDB) but both require changes for me to be workable. The changes i need for Template Lite is the caching system.

Currently you can cache a page or don't cache a page and that's about it.
what i need is this:

<cache start>
code…
[…]
<cache interrupt>
[…]
code that doesn’t need to be cached
should be here…
[…]
<cache resume>
[…]
other code that’s cached
[…]
<cache interrupt>
[…]
o wait.. we need to get this out of the cache as well
[…]
<cache resume>
[…]
the last parts of the page
[…]
<cache end>

So (highly) flexible caching.
the example is a little strange for in Template Lite so this is probably more suitable for template lite:

test.tpl Contents

Code: Select all
                    <table cellspacing="0" border="0" cellpadding="0" width="100%" style="border: 2px solid #E8E8E8; padding: 5px;">
                      <tbody>
                        <tr>
                          <td class="info_top">
                            <span class="category_top_info"><a href="#">Filename</a></span>
                          </td>
                          <td class="info_top" style="width: 100px;">
                            <span class="category_top_info"><a href="#">Downloads</a></span>
                          </td>
                          <td class="info_top" style="width: 60px;">
                            <span class="category_top_info"><a href="#">Other</a></span>
                          </td>
                        </tr>
{ INTERRUPT_CACHE }
{ foreach value=row from=$files }
                            <tr>
                                <td id="{ $row.file_id }" class="info_left_container" onMouseOver="$(this).highlightFade('#FFFEBB');" valign="middle">
                                    <div class="info_left"><a href="index.php?act=file&amp;id={ $row.file_id }">{ $row.file_name }</a></div>
                                    <div id="PLACEHOLDER_{ $row.file_id }" style="display: none;">
                                    </div>
                                </td>
                                <td class="info_middle" onMouseOver="$(this).highlightFade('#C8FFC2');" valign="middle">
                                    { $row.file_dls }
                                </td>
                                <td class="info_right" onMouseOver="$(this).highlightFade('#C8FFC2');" valign="top" style="text-align: center;">
                                    <!-- { $row.file_dls } -->
                                    <a href="#"><img src="./templates/images/kget.png" style="border-style: none;" alt="" /></a>
                                    <a id="HREF_{ $row.file_id }" href="javascript:toggleID('PLACEHOLDER_', '{ $row.file_id }');"><img src="./templates/images/kget.png" style="border-style: none;" alt="" /></a>
                                    <a href="#"><img src="./templates/images/kimproxyonline.png" style="border-style: none;" alt="" /></a>
                                </td>
                            </tr>
{ /foreach }
{ RESUME_CACHE }
                      </tbody>
                    </table>
                { elseif $data_cat_count > 0 }
                    <div style="height: 5px;"></div>
                    <table cellspacing="0" border="0" cellpadding="0" width="100%" style="border: 2px solid #E8E8E8; padding: 5px;">
                      <tbody>
                        <tr>
                          <td class="no_files_or_cats">
                            Sorry, No files to display.
                          </td>
                        </tr>
                    </table>
                { /if }


Now note the: { INTERRUPT_CACHE } and { RESUME_CACHE }.. the ability to do things like this would really help me (and i bet alot of people) a lot.

Furthermore a more advanced cache in the php code would be a welcome addition as well.. a example:

Code: Select all
<?php

[...]

if($tpl->Cache->InCache('long_big_array', 3600))
{
   $tpl->Cache->Display('long_big_array');
}
else
{
   $tpl->Cache->Start('long_big_array', 3600);
   $arr = array("one", "two", "three");
   reset($arr);
   while (list(, $value) = each($arr)) {
      echo "Value: $value<br />\n";
   }

   foreach ($arr as $value) {
      echo "Value: $value<br />\n";
   }
   $tpl->Cache->End();
}

[...]

?>

I believe something like the above is possible with the current caching in Template Lite but not the way i describe it above. This would also really help me in Template Lite. i got this idea from the Zend Framework caching system: http://framework.zend.com/manual/en/zend.cache.html

Let me know what you think of it.
Mark.
markg85
 
Posts: 1
Joined: Mon Sep 03, 2007 8:33 am

Return to Template Lite Discussion Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron