RedJumpsuit

jobberBase custom development and support

 

Code School

Clear Cache

here is how you clear your jobberBase website cache (useful when updating the template, this will force refresh all your css, js and asset files to load a brand new cache)

cache

create a php file called page_clearcache.php under /admin:

<?php 
$user_cache = '../_templates/' . THEME . '/_cache/'; 
$admin_cache = '_templates/_cache/'; 
 
foreach(glob($user_cache .'*.php') as $uc) 
{    
unlink($uc); 
} 
$smarty->assign('user_success', 1);
 
foreach(glob($admin_cache .'*.php') as $ac) 
{
  unlink($ac);
}
$smarty->assign('admin_success', 1);
?>

add in the case under /admin/index.php

// clear cache
case 'clear-cache':
	if(!isset($_SESSION['AdminId']))
	{
		redirect_to(BASE_URL);
		exit;
	}
	require_once 'page_clearcache.php';
	$template = 'clear-cache.tpl';
	$flag = 1;
	break;

update /admin/header.tpl and look for this:

{section name=index loop=$settings_categories}
	<li><a href="{$BASE_URL_ADMIN}settings/{$settings_categories[index].var_name}/">{$settings_categories[index].name}</a></li>
{/section}

admin-clear

then add this right after:

	<li><a href="{$BASE_URL_ADMIN}clear-cache/">Clear Cache</a></li>

create a template file under /admin/_templates called clear-cache.tpl and put this:

{include file="header.tpl"}
<div id="content">
<h2 id="password">Clear Cache</h2>
{if $user_success}
		User cache cleared. 
 
	{/if}
	{if $admin_success}
		Admin cache cleared. 
 
	{/if}</div>
<!-- #content -->
{include file="footer.tpl"}

admin-clear-ok

Tagged as: , ,

1 Comment

Code School

  1. Hi im running 9.1 (I think) and was trying to implement this hack.

    the line that threw an error was:
    foreach(glob($user_cache .’*.php’) as $uc)
    {
    unlink($uc);
    }
    $smarty->assign(‘user_success’, 1);

    More specificly one of the parameters in the foreach was wrong.

    Is this because i am running a more or less vanilla version of jobberbase?
    what is $user_cache?

    could it have something to do with the fact that /admin/header.tpl was in a differnt place in my installation. (I don’t see why it would though…)

    Regardless, I love your site. Thanks for the info!

Leave a Response