Question about caching [SOLVED]

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
LeisureLarry

Question about caching [SOLVED]

Post by LeisureLarry »

I´m working on a very bad implemented members area for one of my customers. The former coders have done it the following way:

1. They made content page let´s say with the id 40 (not cached).
2. They made a special template for this page.
3. This template has no $content in it, but a $customerContent for a user defined tag.
4. In the user defined tag they made an if statement for the login and decided to show:
a) the page with id 40 (direkt grabbing from the db and using a print statement)
b) custom content depending on the login

Now I´m working on implementing the usage of smarty in this solution.
The problem is that I need to render code from a string using smarty-tags.
The following way this would work (code of the user defined tag):

function bb_replace($tpl_source, &$smarty)
{
$page = '';
if (...) {
$page .= 'a';
}
} else {
$page .= 'b';
}     
}
return preg_replace("//", $page, $tpl_source);
}

global $smarty;
//$smarty->caching = 0;
//$smarty->clear_all_cache();

$smarty->register_prefilter("bb_replace");
$smarty->fetch("file:(...)customer.tpl", null, null, true);

I only need a special template which simply contains:

and nothing else.

I only have one problem with this new solution:
CMS MS caches this page (even if the content page has selected no caching)!

Therefore if I reload this page and the if statement would be the other case as before,
it shows the same as before. Deleting the cache in the admin interface, solves the
problem for the next site loading, but after that it´s cached by CMS MS.

I tried the two commented lines in the user defined tag, but that didn´t solved my
problem. Does anybody know how and where I can deactivate the caching for this page?

Greats from Germany
LeisureLarry
Last edited by LeisureLarry on Fri May 11, 2007 8:27 am, edited 1 time in total.
LeisureLarry

Re: Question about caching

Post by LeisureLarry »

One thing to notice:

$page contains in case b user defined tags or module tags, therefore this is why I need smarty.
Pierre M.

Re: Question about caching

Post by Pierre M. »

Hello LeisureLarry,

This topic is far too much deep inside CMSms internals for me. I have just a simple (silly) question :
What about unchecking the "cachable" flag in the options tab in the admin of the page ?
Sorry if this is irrelevant due to the internal tweakings.

Pierre M.
LeisureLarry

Re: Question about caching

Post by LeisureLarry »

@Pierre M.  (thanks for your reply):

That´s why I wrote:
1. They made content page let´s say with the id 40 (not cached).

The content page itself has selected in its options tab to not be cached.

I simply don´t know why its cached, even if caching is disabled.

Besides the installation is CMS MS 1.06, just to mention.
LeisureLarry

Re: Question about caching

Post by LeisureLarry »

Does noboy have a clue, where cms ms / smarty is caching this content and how I can disable this behaviour.
cyberman

Re: Question about caching

Post by cyberman »

Have you tried to switch off caching in /lib/content.functions.php in line 56?

Code: Select all

		$this->caching = false;
Last edited by cyberman on Mon May 07, 2007 9:43 am, edited 1 time in total.
LeisureLarry

Re: Question about caching

Post by LeisureLarry »

Thanks cyberman, it wasn´t the correct line, but this file helped me a lot.

My user defined tag is now:

function bb_replace($tpl_source, &$smarty)
{
$page = '';
if (...) {
$page .= 'a';
}
} else {
$page .= 'b';
}   
}
return preg_replace("//", $page, $tpl_source);
}

global $smarty;
$smarty->caching = false;
$smarty->force_compile = true; // THIS SOLVED THE PROBLEM

$smarty->register_prefilter("bb_replace");
$smarty->fetch("file:(...)customer.tpl", null, null, true);
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Question about caching

Post by tsw »

force compile will slow page rendering considerably, but it might be the only option for you
LeisureLarry

Re: Question about caching

Post by LeisureLarry »

As this solution is only implemented in one single page, I don´t think it will be a great problem.

But thanks for the info.

Greats from Germany
LeisureLarry
Locked

Return to “CMSMS Core”