Demo: cache, Cache UNIQUE sections

Welcome to Demo: cache, Cache UNIQUE sections

This is cached header section

Header sdfsdf

another section



The End
Control

										
include_once( 'includes/pTemplate.php' );

$cached_header = $pTemplate->cache('live_header');
if( !empty($cached_header) )
	$pTemplate->assign_var('CACHED_HEADER', $cached_header);
else
	$live_header = true; // MUST enable section if want to cache it

$pTemplate->add_file( 'templates/cache_section.html' );
// MUST apply parse_file to get parsed result before cache it
$output = $pTemplate->pparse_file( 'templates/cache_section.html' );
 
// cache header section
if( $live_header ) // still have not cache of this section yet
	$pTemplate->cache( 'live_header', $pTemplate::PCACHE_SET );
 
echo $output;
exit;
										

[=CACHED_HEADER=]
			
<!-- START_SECTION live_header -->
<b>Header</b>
<ul class="unstyled">
	<!-- BEGIN_LOOP social_list -->
	<li>
		<a href="" title="">
			<i class=" smaller"></i> 
		</a><br />
		<span> </span>
		<br /><br />
	</li>
	<!-- END_LOOP social_list -->
</ul>
<!-- STOP_SECTION live_header -->

Other demos

View Online Documentation