User Login    
 + Register
Bookmark and Share
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!





(1) 2 »


Re: Module Caching DOESN'T work!! Follow-up
Home away from home
rank4823bd3e90096.gif
Joined:
2003/11/21 8:08
From Copenhagen, Denmark
Group:
Forge Developers
Registered Users
Posts: 841
Edit: NM

Thought the template was fetched twice, but overlooked the
exit();
call in the header.php

Posted on: 2004/1/28 15:57
_________________
Knowledge = Power
Power = Energy
Energy = Matter
Matter = Mass
So a good bookshop is really just a genteel black hole, which knows how to read
---
Consulting
ShowCase
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Home away from home
rank4823bd3e90096.gif
Joined:
2003/11/21 8:08
From Copenhagen, Denmark
Group:
Forge Developers
Registered Users
Posts: 841
Right - but how do I get the module configuration? been a while since I looked at this, but is this included/set in common.php, which is included in mainfile.php? (could look myself, but there are wemminz playing handball on TV :-D)

edit: OK, took a look myself.
Common includes all the behind-the-scenes things
header.php sets up blocks, footers and caching, so you are absolutely right. Including mainfile as the first, then find out, which template to use, then include header.php

Posted on: 2004/1/28 15:40
_________________
Knowledge = Power
Power = Energy
Energy = Matter
Matter = Mass
So a good bookshop is really just a genteel black hole, which knows how to read
---
Consulting
ShowCase
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Just can't stay away
rank4823bd1d117e3.gif
Joined:
2003/11/21 9:30
From Toronto, Canada
Group:
Forge Developers
Registered Users
Posts: 101
You'll have to put the header call below that part then.

Posted on: 2004/1/28 15:07
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Home away from home
rank4823bd3e90096.gif
Joined:
2003/11/21 8:08
From Copenhagen, Denmark
Group:
Forge Developers
Registered Users
Posts: 841
This should be relayed to the module writers asap, I think.

Only problem is if the template is not known until the code is executed.

I use this in the new News module, where it depends on a module config setting, whether the template to be used is the current one or the news-by-topic one, I made.

Posted on: 2004/1/28 13:51
_________________
Knowledge = Power
Power = Energy
Energy = Matter
Matter = Mass
So a good bookshop is really just a genteel black hole, which knows how to read
---
Consulting
ShowCase
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Just can't stay away
rank4823bd1d117e3.gif
Joined:
2003/11/21 9:30
From Toronto, Canada
Group:
Forge Developers
Registered Users
Posts: 101
Nope, scratch everything I've said. I've found the culprit.

In your modules you MUST call

$xoopsOption['template_main'] = "";

before calling the header.

include XOOPS_ROOT_PATH.'/header.php';

If you do this everything seems to work just dandy without having to add anything to your code.

I found the problem in this chuck of the header:

Quote:

if ($xoopsTpl->is_cached($xoopsCachedTemplate, $xoopsCachedTemplateId)) {



If you don't call the template to be used first, then it passes db:system_dummy.html as the $xoopsCachedTemplate instead of the actual template. So what happens is this returns false and skips the code included in the if statment below it that basically says if the templates exists don't run the page, which is what we wanted.

I assume the reason we were still get the cached page after running the "index.php" page is that there's something that's run in the footer, or smarty itself on display() (I haven't looked) that once it knows what the template is it checks on it's own for a cached version, but at this point we are long past the if{} in the header.php file.

In conclusion, as long as you state the template to be used before calling the header it seems to work properly, sorry for all the confusion.

We really need documentation for these little minor things that can really bugger up a module.

It seems the news does this properly but quite a few other modules don't, so we'll have to go through each of them to check.

Posted on: 2004/1/28 11:57
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Home away from home
rank4823bd3e90096.gif
Joined:
2003/11/21 8:08
From Copenhagen, Denmark
Group:
Forge Developers
Registered Users
Posts: 841
OK, so it is mainly a question about getting existing functions incorporated in the modules?

If that's all it takes, I think it should be possible.

Posted on: 2004/1/28 11:46
_________________
Knowledge = Power
Power = Energy
Energy = Matter
Matter = Mass
So a good bookshop is really just a genteel black hole, which knows how to read
---
Consulting
ShowCase
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Just can't stay away
rank4823bd1d117e3.gif
Joined:
2003/11/21 9:30
From Toronto, Canada
Group:
Forge Developers
Registered Users
Posts: 101
Quote:

Mithrandir wrote:
Kazu, I think the problem is that the php code below the include() line is executed anyway, since there is no branch off in the header.php, so it just continues down in e.g. the index.php and does all the sql statements and assigns them to xoopsTpl, which doesn't use it, since there is already a cached version of the page.

I guess something like this:
//header.php - last line
if (!$module_is_cached) {

//open { to put the index.php contents in there
index.php contents

//footer.php - first line
}
else {
//use cached version (if it is necessary to specify that?)
}


Exactly, regardless where the 'header' is included, the rest of the page (index.php for instance) is still ecxecuted unless you tell it not to. And even if it did "break and exit" after the header part it still won't work. I've found that you still need to run:

$xoopsOption['template_main'] = 'hs_index.html'

AND

include_once XOOPS_ROOT_PATH.'/footer.php';

inorder for the cached version to show.

Basically this is what one of my index pages looks like now..

Quote:
<?

include '../../mainfile.php';
include XOOPS_ROOT_PATH.'/header.php';
include XOOPS_ROOT_PATH.'/modules/hosting/class/package.php';


// Template call
$xoopsOption['template_main'] = 'hs_index.html';

// Check to see if module is cached
if(!$xoopsTpl->is_cached($xoopsCachedTemplate)){

echo "not cached";
// Get packages
$package = new package();
$xoopsTpl->assign('package',$package->getPackage(1));

// Grab text for page
$result = $xoopsDB -> query( "SELECT * FROM " . $xoopsDB -> prefix( "hosting_content") . " WHERE page = 'index.php'" );
while( $myrow = $xoopsDB->fetchArray($result) ){
$text = $myrow['content'];
}

$xoopsTpl->assign('text',$text);

} // End module cache


include_once XOOPS_ROOT_PATH.'/footer.php';
?>


Now if the module is cached, the echo "not cached" disappears and the mysql call below it isn't run, but the results are shown on the final output from the cahce.

Posted on: 2004/1/28 11:13
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Just can't stay away
rank4823bd1d117e3.gif
Joined:
2003/11/21 9:30
From Toronto, Canada
Group:
Forge Developers
Registered Users
Posts: 101
Quote:

onokazu wrote:
However since we had many other problems regarding the use of the module wide caching feature, I think that we should drop the current caching system and create new APIs (with or without Smarty) and let the modules use them where needed.


What other problems? As far as I can tell, as long as you wrap all your code in an if statement it solves the pronlem. Is there another problem with the cache?

Posted on: 2004/1/28 11:08
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Home away from home
rank4823bd3e90096.gif
Joined:
2003/11/21 8:08
From Copenhagen, Denmark
Group:
Forge Developers
Registered Users
Posts: 841
Kazu, I think the problem is that the php code below the include() line is executed anyway, since there is no branch off in the header.php, so it just continues down in e.g. the index.php and does all the sql statements and assigns them to xoopsTpl, which doesn't use it, since there is already a cached version of the page.

I guess something like this:
//header.php - last line
if (!$module_is_cached) {

//open { to put the index.php contents in there
index.php contents

//footer.php - first line
}
else {
//use cached version (if it is necessary to specify that?)
}

Posted on: 2004/1/28 10:47
_________________
Knowledge = Power
Power = Energy
Energy = Matter
Matter = Mass
So a good bookshop is really just a genteel black hole, which knows how to read
---
Consulting
ShowCase
_MD_TRANSFER_DESC _MD_TRANSFER


Re: Module Caching DOESN'T work!! Follow-up
Quite a regular
rank4823bcc150ffb.gif
Joined:
2003/11/7 9:09
Group:
Registered Users
Posts: 46
I think I have finally understood the problem you were having. Since the caching routines are all written in header.php, all the queries and function calls get executed if they are written prior to the line where header.php is include'd.

To avoid this, you would have to always include the header.php file first, and all other parts of the code should be written below that include() line so that those parts will not be executed if the template file to be used there is already cached.

However since we had many other problems regarding the use of the module wide caching feature, I think that we should drop the current caching system and create new APIs (with or without Smarty) and let the modules use them where needed.

Posted on: 2004/1/28 8:48
_MD_TRANSFER_DESC _MD_TRANSFER




(1) 2 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create pdf.
You cannot get print page.

[Advanced Search]