IncludeFile-Talk

Summary: Talk page for IncludeFile.
Maintainer: ThomasP
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Comments

I used the following code to include files directly from the upload directory of the group where the markup is placed:

# Create markup that allows including files directly into wiki pages (IncludeFile recipe)
Markup('includefile', 'inline', '/\\(:includefile\\s+([-\\w.]+)\\s*:\\)/e',
  "includeTextAsPreFunc('$1', 'style=\"font-size:9pt;\"')");

$WikiRootDir = $_SERVER['DOCUMENT_ROOT']  . "/pathToMyWiki";
$groupname = substr($GLOBALS['pagename'], 0, strpos($GLOBALS['pagename'], "."));

function includeTextAsPreFunc($filename, $htmlAttribs) {
  global $WikiRootDir;
  global $groupname;

  $fullfilename = "$WikiRootDir/uploads/$groupname/$filename";
  if (file_exists($fullfilename)) {
    $filecontents = file($fullfilename);
    return Keep('<pre ' . $htmlAttribs . '>' . implode('', $filecontents) . '</pre>');
  }
  return Keep("(:includefile $filename:) failed: Could not open $filename in group $groupname.<br>\n");
}

Note that this also puts the file content into a pre environment. pathToMyWiki has to be the fragment of the path starting from below your htdocs directory and leading to pmwiki.php, so in case of /somesharedserver/customerNo27654/htdocs/mywiki/pmwiki.php it is just /mywiki.

I also tried (:includefile ../SomeOtherGroup/myPrivateFile.txt:) but this failed (I have the SecureAttachments recipe installed), so I assume it is safe (comments?). 13/08/2006 ThomasP


Can I add a .cgi file too that will produce output via the post method?

No. As this recipe is mainly for including the contents of a file, this should be done in a separate recipe.


07.23.06

Can the html files be included during search?

A: Not by interpreting the html, only the content of the html files.

2007.08.29 NeI

I have discovered that I can create a directory $FarmD/uploads/GROUP and put my GROUP specific text file in that directory. Is there are way to have another directory under $FarmD other than ./uploads/GROUP? I don't want to use either ./uploads or ./uploads/GROUP.

A: There is a way to upload to page specific directories, a la uploads/GROUP/PAGE/myfile.txt. (Check out the config vars, probably just set $UploadPrefixFmt = '/$Group/$Name';.) ThomasP December 07, 2007, at 04:06 AM

There is a slight background highlighting of a text file I'm including in the Wiki page. In this case just like that seen when I use the markup [@ ...text... @]. Can I get rid of this background highlighting somehow?

A: The file text is wrapped in a code tag with class "escaped". If you can allow it to adjust this css class in your css file then things are probably done. Another idea is to extend the code in IncludeFile.php around variable "htmlStyles" to allow also for background color options. ThomasP December 07, 2007, at 04:06 AM

Thanks for this. I have it working...BUT, I am trying to get the include to bring in a text file that includes code for the wiki itself, so that in the page, the right words are bolded, and it's formated correctly for the layout of the wiki. When it pulls the txt file in however, it just outputs the code as code. I have tried a few things, and am stuck. Is it possible to do this, or am I better of creating 26 pages of normal wiki pages, as I am creating a lexicon, and need a dictionary like page setup? TIA

Can I embed .pdf files directly into my page??? Franzi

Talk page for the IncludeFile recipe (users?).