Categories > TinyButStrong general >

Cach with login system

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Pablo Impallari
Date: 2006-09-13
Time: 10:14

Cach with login system

Hi:
In many sites, I have 2 links in the headers.
1) Login
2) Register

After de user has logged in, those 2 links chages to:
1) Hello "XXXXXX" User
2) LogOut

So, te question is:
How can i have cache the rest of the page, but not this login widget, that must be independet from the rest of the content.

Sorry about my english, im from Argentina.
By by
By: TomH
Date: 2006-09-13
Time: 19:39

Re: Cach with login system

Hi,
If I were doing I would make a parent page that was not cached and which holds the logon elements, and then -- inside that HTML template --  I would place a subtemplate that would be the cached content.

Kind of like this...
Parent page like index.HTML
1) Login <!-- from what you already have -->
2) Register <!-- from what you already have -->

Blah, blah

[onload;script=mainpage_cached_content.php;subtpl]

Blah footer, blah.
Then the PHP script for mainpage_cached_content.php
$cachesecs=7200;  // or to fit your site

if( !$this->PlugIn(TBS_CACHE,$cache_id, $cachesecs) ) {

    $this->LoadTemplate('mainpage_cached_content.html') ;

    $sql="SELECT DISTINCT left(lname,1) AS fletter from mycontacts ORDER BY lname";

    $db->get_results($sql);   // I only use ezSQL db class in TBS
    $this->MergeBlock('blk',$db);
    $this->Show();
}

Hope that helps get you started,
TomH
By: Pablo Impallari
Date: 2006-09-14
Time: 01:28

Re: Cach with login system

Is there any other way to do it whitout breakign the main template in subtemplates?

I dont want to end up whit a lot of subtmeplates for every page on the site.
By: TomH
Date: 2006-09-14
Time: 10:57

Re: Cach with login system

I see it as only one small page/script that is a wrapper that includes the login widget and the one subtemplate that is the rest of the content.

And that wrapper will only change if you need to change the login widget.

So you would only be worlking with the one main content subtemplate for all other things that you needed to code.

You can look at my TBS caching examples for some more ideas on caching content -- the "model 3" example is a page that is ALL in one script. In your case it would be analagous to the main content and would be inside of your login wrapper script.

Also see the Meta123 CMS prototype -- 90% of the content views/pages are generaated from the parent script's db queries.

See examples at http://tomhenry.us/tbs3/

HTH,
TomH
By: Pablo Impallari
Date: 2006-09-15
Time: 06:29

Re: Cach with login system

Thank so much.
The examples are great!