Tuesday, February 21, 2006

how to fix Warning: extract(): First argument should be an array

Re: [maxbear] Error using different template [In reply to] Can't Post

--------------------------------------------------------------------------------

It looks like the error is happening on this line:

--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

extract($TPL_GLOBALS[$template_set]);

--------------------------------------------------------------------------------


Which from the previous few lines, should only error if you don't have a globals.txt. You should be able to fix it by either creating an empty globals.txt file, or by changing the above line to:

--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

if (isset($TPL_GLOBALS[$template_set])) {
extract($TPL_GLOBALS[$template_set]); }
-------------------------------------------------------------------------------

in aboutsaigon/includes/templates.php

function fetch($file = null) {
global $INFO;
if(!$file) $file = $this->file;
if (isset($this->vars)) { // fix the warning
extract($this->vars);
}
ob_start();
include($INFO['templateFolder'].$file.$INFO['templateType']);
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
}

No comments: