PDA

View Full Version : Question about $templatesused...


cirisme
05-13-2003, 07:25 PM
What's the easiest way to tell if a template is being called that is not on the templatesused list?

Boofo
05-13-2003, 07:32 PM
Look in the php file. ;)

cirisme
05-13-2003, 07:56 PM
Hehehehe, I was hoping for a log or something. Oh well. ;)

rake
05-13-2003, 08:19 PM
use explain=1 on pages. Look for a query like SELECT * FROM template WHERE title IN (blah,blahblah,blahblah) ;)

Boofo
05-13-2003, 09:27 PM
Or you could do that. ;)

filburt1
05-13-2003, 09:35 PM
You can also very easily modify gettemplate to echo the names of uncached templates when they're eval'ed. That's what I do on my test board to make sure $templatesused is correct.

Boofo
05-13-2003, 09:50 PM
How would you do that? I'd like to try it.

filburt1
05-13-2003, 10:23 PM
I don't have a reference vB2 functions.php ATM but if you have my embed PHP tags in templates hack installed, find:

if (isset($templatecache[$templatename]))
{
$toreturn = $templatecache[$templatename];
}
else
{
$template = $DB_site->query_first("SELECT template FROM template
WHERE title = \"" . addslashes($templatename) . "\"
AND (templatesetid = -1 OR templatesetid = $templatesetid)
ORDER BY templatesetid DESC LIMIT 1");
$toreturn = $template['template'];
$templatecache[$templatename] = $toreturn;
}

Replace with:

if (isset($templatecache[$templatename]))
{
$toreturn = $templatecache[$templatename];
}
else
{
echo "Template <b>$templatename</b> wasn't cached!<br>";
$template = $DB_site->query_first("SELECT template FROM template
WHERE title = \"" . addslashes($templatename) . "\"
AND (templatesetid = -1 OR templatesetid = $templatesetid)
ORDER BY templatesetid DESC LIMIT 1");
$toreturn = $template['template'];
$templatecache[$templatename] = $toreturn;
}

Boofo
05-13-2003, 10:34 PM
Here's what I have for that code:

if (isset($templatecache[$templatename])) {
$template=$templatecache[$templatename];
} else {
$gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' AND (templatesetid=-1 OR templatesetid=" . intval($templatesetid). ") ORDER BY templatesetid DESC LIMIT 1");
$template=$gettemp[template];
$templatecache[$templatename]=$template;
}

filburt1
05-13-2003, 11:36 PM
Then right above that query, add:

echo "<b>$templatename</b> isn't cached!<br>";

Boofo
05-14-2003, 12:09 AM
How can I make this so it only shows the un-cached templates for the admin only?

Thank you for the code, by the way. I am finding a few spots where I must have missed a few templates. ;)

Tigga
05-14-2003, 12:28 AM
Something like this should work...

if ($bbuserinfo['usergroupid']=='6') {
echo "<b>$templatename</b> isn't cached!<br>";
}

Boofo
05-14-2003, 12:48 AM
Thanks, Tigga. ;) That's what I had but I wanted to make sure it wouldn't mess anything up with the "} else {" right above it.

LOL filburt, you are gonna love this one. Take a look at your file cannedtext.php and you'll notice that you have $templateused instead of $templatesused in both spots. ;)

Erwin
05-14-2003, 01:14 AM
Good tip, filburt1. :) Should release it as a mini-hack.

Erwin
05-14-2003, 01:17 AM
Just confirming, the code should end up looking like this:


if (isset($templatecache[$templatename])) {
$template=$templatecache[$templatename];
} else {
if ($bbuserinfo['userid']=='1') {
echo "<b>$templatename</b> isn't cached!<br>";
}
$gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' AND (templatesetid=-1 OR templatesetid=" . intval($templatesetid). ") ORDER BY templatesetid DESC LIMIT 1");
$template=$gettemp[template];
$templatecache[$templatename]=$template;
}

filburt1
05-14-2003, 01:19 AM
Are you sure $bbuserinfo is in the global scope there?

Erwin
05-14-2003, 01:44 AM
It's not, but I've added it. Is that the right place to put the echo bit?

Erwin
05-14-2003, 01:45 AM
I assume it is since it works...

Boofo
05-14-2003, 08:54 AM
And I also found out the hard way that you have to add $bbuserinfo to the global statement right above it or it won't work. ;)