Plugin not working with EE2
-
George Ornbo
- Milestone order changed from 0 to 0
(I'm not George; I simply clicked the Tickets link here: http://shapeshed.github.com/expressionengine/plugins/filesize/ which automatically logged me in as him.)
I found the same bug with this plugin:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: human_filesize/pi.human_filesize.php
Line Number: 66
I took a look on line 66 of the plugin and I found this:
$this->file = trim(strip_tags($TMPL->tagdata));and figured the error must have something to do with $TMPL, so I stuck an
ifstatement around that line like this:if ($TMPL) { $this->file = trim(strip_tags($TMPL->tagdata)); }and now I don't get that error anymore.
Hope this helps someone!
-
ffub
The above fix will hide the error, but the plugin will not be able to access the actual filename. The below works in EE2, untested in EE1.
Replace:
$this->file = trim(strip_tags($TMPL->tagdata));with:
$this->EE =& get_instance(); $this->file = trim(strip_tags($this->EE->TMPL->tagdata));A conditional may be necessary to add support for EE1:
if ($TMPL) { $this->file = trim(strip_tags($TMPL->tagdata)); } else { $this->EE =& get_instance(); $this->file = trim(strip_tags($this->EE->TMPL->tagdata)); }The above is untested in EE1 though as I do not have an installation handy.
Thanks,
Stephen -
masni bennett
This is how I hacked it recently to get it working with full file paths.
function Human_filesize() { global $TMPL, $FNS; $this->EE =& get_instance(); // Grab the site url $path = $this->EE->functions->fetch_site_index(); $path = str_replace("index.php", "", $path); $this->file = trim(strip_tags($this->EE->TMPL->tagdata)); $this->file = str_replace($path, "", $this->file); // Remove the site url $this->file = str_replace(SLASH, '/', $this->file); if (!file_exists($this->file)) { return $this->error_message; } // Continue with original code...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.