Categories > TinyButStrong general >

Cache Problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Deathtone
Date: 2005-03-18
Time: 19:46

Cache Problem

I'm having a problem, i'll try explaning this as best as i can to see if someone can help me out.. i'm using the cache system on a specific file that everyone who visits the site loads automatically, on the same file I have a variable that changes acording to the theme that the user has currently selected on his profile.

Now this is a problem because the next person that loads the site, is not going to see this file with the theme that he/she has currently selected, but with the theme that is currently cached, for example, if [var.theme] is "blahblah" all users that load the cached file will load the file using with a link to "blahblah.css".

Is it possible to cache just certains parts of HTML ? If it is, how can i do it ?

Thanks
By: Outer
Date: 2005-03-19
Time: 15:09

Re: Cache Problem

Why not just cache all different themes, and call the cache file according to which theme you have since the [var.theme] is already loaded onto the file....
By: Deathtone
Date: 2005-03-19
Time: 17:45

Re: Cache Problem

yeah, i figure it could be done like that, but i can't help but think that there must be a better/easier way.. check out my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Shoutbox</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/[var.theme].css" rel="stylesheet" type="text/css">
</head>

<body class="body_shoutbox">
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="shoutbox_padding">
<form method="POST" action="shoutbox.php?op=apagar">
<admin_links>
[onshow;block=admin_links;when [var.nivel]='5']
<input type="submit" value="apagar!">
</admin_links>
<tag_loop>
  <tr>
    <td>
      <strong>
      <admin_links>
      [onshow;block=admin_links;when [var.nivel]='5']
      <input type="checkbox" name = "shouts[]" value = "[shoutbox.id]">
      </admin_links>
      [shoutbox.autor]</strong> @ [shoutbox.hora] [shoutbox.data]</td>
  </tr>
  <tr>
    <td>[shoutbox.texto;htmlconv=no;block=tag_loop]</td>
  </tr>
</tag_loop>

..now, if there was a way to use the caching, starting on the <body> tag, the [var.theme] wouldn't be affected and therefore, there would be no problem, if it can't be done like this, then I guess your suggestion would be the best way to go :)
By: Skrol29
Date: 2005-03-20
Time: 01:38

Re: Cache Problem

Hello,

Instead of using a Var field for your theme, you can use a custom field that you will merge when you want using MergeField() method.

For exemple, with the template:
<link href="css/[theme].css" rel="stylesheet" type="text/css">

you can have the following code:
$TBS->Render = TBS_NOTHING;
...
$TBS->LoadTemplate(...);
...
$TBS->MergeField('theme',$theme);
echo $TBS->Source; // Display the result
exit;

In this code, you we set the Render property to TBS_NOTHING in order to   avoid the display and exit of the code when the cache file is automatically loaded and shown.