By: TomH
Date: 2010-09-20
Time: 18:01
|
CACHENOW & Render NOTHING inside a functionI have been trying some new things (for me) and I searched this forum for related coding as a way to see if I was on track.
Some code by Skrol29 & Pirjo Posio has inspired me to to take the next step and make a function to do the dirty work. In this function I want to be able to interrupt the TBS processing for the current page and do the following: * read in a template having TBS blocks * populate the blocks with db content * save (cache) the merged template file for later use * resume TBS processing for the current page I want this scheme to cache merged template(s) so that they can be used in all the other pages of the site without the other pages having to do ANY PHP/db processing. Here's my attempt at a function to do this -- it actually seems to be working - it does create the merged subtemplate. And it does expire and re-build the merged files as expected. I see no evidence "yet" that it is breaking the TBS for the current page. ((But this stuff really scares me!))
Here's the function as it's being used in the PHP page script
I would greatly appreciate a detailed critique of this approach -and- any warnings of weaknesses or outright errors. You can see a prototype of this at http://tomhenry.us/tbs3/cachenow_merged/contacts_merged_func.php sometimes it's easier to understand code when the page can be seen. Thanks very much for any guidance you can give. And thanks for TBS every day, TomH |
||
By: TomH
Date: 2010-09-20
Time: 18:15
|
Re: CACHENOW & Render NOTHING inside a functionOoops,
That link should have been http://tomhenry.us/tbs3/cachenow_merged/contacts_merged_func2.php Sorry, |
||
By: Skrol29
Date: 2010-09-21
Time: 21:49
|
Re: CACHENOW & Render NOTHING inside a functionHi TomH,
1) Why don't you put the source swap into the function?
2) In the following part, I'm surprised that you need to swap the Render:
Otherwise, it seems ok |
||
By: TomH
Date: 2010-09-21
Time: 23:40
|
Re: CACHENOW & Render NOTHING inside a functionSKrol29,
Thanks for your comments. I did make those changes you recommended and the function works fine (that did not surprise me except for the part of eliminating the Render swap!). But that means there's something I don't understand about the Source property... Here's the current function
I can understand that $main_template = $TBS->Source; saves the main Source -- but I don't see how then the Source only contains the source from $TBS->Source = $template; ready for the Merge ??? What is happening that makes Source empty before the $TBS->Source = $template; statement? Thank you for your patience, and thanks for TBS every day, TomH |
||
By: Skrol29
Date: 2010-09-23
Time: 09:29
|
Re: CACHENOW & Render NOTHING inside a functionHi,
> What is happening that makes Source empty before the $TBS->Source = $template; statement? Source does not become empty. It is just swaped. |