1

I'm currently developing a custom module and for some reason it appends a blank space before anything I'm outputting. My set up is like this:

main class is in helper .php, logic is in mod_name .php, output is in /tmpl/default .php

The strange thing is that if I have a method in my class that returns html. And then I call this method in my template everything's fine no extra lines are appended. But if I try to write output, even plain text, in my template or mod_name.php I get this extra line.

Here's a screenshot: enter image description here

Please let me know if anyone encountered anything like this before, I'd be much obliged!

michaeltintiuc
  • 671
  • 15
  • 31

4 Answers4

3

Turned out that the problem was because I was including 2 files, each of them contained a separate class, for some reason when I was including only 1 file it all worked fine. The included file had no white-space and wasn't generating any output, it contained only the logic. Thank You for your time and answers though.

EDIT:

Recently stumbled upon this issue again, turned out UTF-8 without BOM is the way to go, BUT MVC-wise, make sure that your components entry point "./com_helloworld/helloworld.php" is UTF-8 without BOM in the first place!

michaeltintiuc
  • 671
  • 15
  • 31
  • Yeah, couldn't figure that my self for a while... somehow the file encoding was adding a blank space enclosed withing double quotes " " Happens to components as well... – droplet Jul 22 '12 at 18:15
2

UTF-8 without BOM is the answer. I made 3 complex Joomla websites with conditional CSS to manage this problem before I found the cause. I also found this script somewhere to put on the root of a Joomla website to recursively autosave UTF-8 no BOM php files. It worked and saved me a lot of time:

<?php 
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
$HOME = dirname(__FILE__);
// Is this a Windows host ? If it is, change this line to $WIN = 1;
$WIN = 0;

// That's all I need
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UTF8 BOM FINDER and REMOVER</title>
<style>
body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; background: #FFF; color: #000; }
.FOUND { color: #F30; font-size: 14px; font-weight: bold; }
</style>
</head>
<body>
<?php
$BOMBED = array();
RecursiveFolder($HOME);
echo '<h2>These files had UTF8 BOM, but i cleaned them:</h2><p class="FOUND">';
foreach ($BOMBED as $utf) { echo $utf ."
\n"; }
echo '</p>';

// Recursive finder
function RecursiveFolder($sHOME) {
  global $BOMBED, $WIN;

  $win32 = ($WIN == 1) ? "\\" : "/";

  $folder = dir($sHOME);

  $foundfolders = array();
  while ($file = $folder->read()) {
    if($file != "." and $file != "..") {
      if(filetype($sHOME . $win32 . $file) == "dir"){
        $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file;
      } else {
        $content = file_get_contents($sHOME . $win32 . $file);
        $BOM = SearchBOM($content);
        if ($BOM) {
          $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file;

          // Remove first three chars from the file
          $content = substr($content,3);
          // Write to file 
          file_put_contents($sHOME . $win32 . $file, $content);
        }
      }
    }
  }
  $folder->close();

  if(count($foundfolders) > 0) {
    foreach ($foundfolders as $folder) {
      RecursiveFolder($folder, $win32);
    }
  }
}

// Searching for BOM in files
function SearchBOM($string) { 
    if(substr($string,0,3) == pack("CCC",0xef,0xbb,0xbf)) return true;
    return false; 
}
?>
</body>
</html>
aymeric
  • 3,877
  • 2
  • 28
  • 42
Daniele Cannova
  • 309
  • 3
  • 5
1

I've encountered a similar problem today, and managed to solve it by encoding the module layout to "UTF-8 without BOM"

0

It looks to be a saved location for something set to hide. I at least have found this at times with print and rss icons turned off, but the container fails to go away. You can remove the whole thing, or make corrections in the database files if you can find the source. Looks like some sort of registration module so could you could look in the source files for any modules you might have like this if that rings a bell. Sorry not an exact answer, but hopefully gives a little direction.

Shane
  • 1,629
  • 3
  • 23
  • 50