Welcome Guest, Not a member yet? Register   Sign In
Combine CodeIgniter with Smarty
#14

[eluser]Rick Jolly[/eluser]
[quote author="Edemilson Lima" date="1200897166"]
"Technical Note: The files in the $cache_dir are named similar to the template name. Although they end in the .php extention, they are not intended to be directly executable."

That is the problem. While CI executes the PHP scripts just once and writes the resulting HTML content to the cache, Smarty compiles the templates and produces a new PHP code that will be re-interpreted again by the PHP engine, not just sent to the browser. Do you understand the difference?[/quote]

No. Both CI and Smarty write cache files that don't contain php. The quote you referenced above points out that although the cache file has a .php extension, it isn't an executable php file. However, both CI and Smarty read the entire cache file and parse metadata from it. CI gets the timestamp from within the cache file, and Smarty gets some additional info.

Smarty's cache implementation is much more powerful than CI's. While CI only allows caching per page (all or nothing), Smarty allows partial caching.

Examples

CI cached file:
Code:
1200900241TS---><html>
<head>
<title>Smarty Test</title>
</head>
<body>
Text: Hello World!</body>
</html>

Smarty cached file:
Code:
129
a:4:{s:8:"template";a:1:{s:8:"test.php";b:1;}s:9:"timestamp";i:1200894979;s:7:"expires";i:1200898579;s:13:"cache_serials";a:0:{}}<html>
<head>
<title>Smarty Test</title>
</head>
<body>
Text: Hello World!
</body>
</html>

Smarty compiled file:
Code:
<?php /* Smarty version 2.6.18, created on 2008-01-20 21:56:19
         compiled from test.php */ ?>
<html>
<head>
<title>Smarty Test</title>
</head>
<body>
Text: <?php echo $this->_tpl_vars['hello']; ?>
</body>
</html>

Smarty template file:
Code:
<html>
<head>
<title>Smarty Test</title>
</head>
<body>
Text: {$hello}
</body>
</html>


Messages In This Thread
Combine CodeIgniter with Smarty - by El Forum - 12-15-2007, 01:21 PM
Combine CodeIgniter with Smarty - by El Forum - 12-15-2007, 01:32 PM
Combine CodeIgniter with Smarty - by El Forum - 12-15-2007, 02:10 PM
Combine CodeIgniter with Smarty - by El Forum - 12-16-2007, 10:39 AM
Combine CodeIgniter with Smarty - by El Forum - 01-04-2008, 05:42 AM
Combine CodeIgniter with Smarty - by El Forum - 01-04-2008, 12:36 PM
Combine CodeIgniter with Smarty - by El Forum - 01-19-2008, 05:39 AM
Combine CodeIgniter with Smarty - by El Forum - 01-19-2008, 06:06 AM
Combine CodeIgniter with Smarty - by El Forum - 01-19-2008, 11:44 AM
Combine CodeIgniter with Smarty - by El Forum - 01-19-2008, 02:32 PM
Combine CodeIgniter with Smarty - by El Forum - 01-20-2008, 04:55 AM
Combine CodeIgniter with Smarty - by El Forum - 01-20-2008, 12:09 PM
Combine CodeIgniter with Smarty - by El Forum - 01-20-2008, 06:32 PM
Combine CodeIgniter with Smarty - by El Forum - 01-21-2008, 12:34 AM
Combine CodeIgniter with Smarty - by El Forum - 01-21-2008, 05:23 AM
Combine CodeIgniter with Smarty - by El Forum - 01-21-2008, 10:56 AM
Combine CodeIgniter with Smarty - by El Forum - 01-21-2008, 03:44 PM
Combine CodeIgniter with Smarty - by El Forum - 01-21-2008, 04:34 PM
Combine CodeIgniter with Smarty - by El Forum - 09-01-2008, 01:46 AM
Combine CodeIgniter with Smarty - by El Forum - 10-18-2008, 08:45 PM
Combine CodeIgniter with Smarty - by El Forum - 07-02-2009, 09:29 AM
Combine CodeIgniter with Smarty - by El Forum - 07-02-2009, 11:29 AM
Combine CodeIgniter with Smarty - by El Forum - 05-10-2012, 11:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB