A small front-end file browser for Pulse

Hi there,
I had a client who wanted to manage many files (pdf,doc,etc.) and folders at his Intranet. I made a simple file browser for Pulse. Maybe you find this useful.

Create a new block: sb_browser.txt
Create a new folder: /content/pages/files
Create a new page: /content/pages/files/index.txt containing {{block:sb_browser}}

Now you can create folders and subfolders at /content/pages/files and copy your files into them. Always copy index.txt to every folder. I did it via ftp.
Link to file browser would be: yourwebsite.com/files/index. Style the results with a little CSS.

One issue: I had to disable Pulse autobackup because it took too long with hundreds of files.

Here comes sb_browser.

// where are we?
$directory = "content/pages".dirname($_SERVER["REQUEST_URI"])."/";
$directory = urldecode($directory);
$folder    = dirname($_SERVER["REQUEST_URI"])."/";
$top       = (basename(dirname($folder)));
$top       = urldecode($top);
$header    = basename($folder);
$header    = urldecode($header);

//read all files 
$files = glob($directory . "*");

<div class="textblock">
<h1><?= $header ?></h1>

// one step up
{  ?>
<p>Back to: 
<a href="<?= dirname($folder) ?>/index"><?= $top ?></a></p>
<?php }  ?>

<table class="sortable block">

foreach($files as $file)
//is it a folder?
{ ?>

<td class="folder"><a href="<?= $folder ?><?= basename($file) ?>/index"><?= basename($file) ?></a></td>
foreach($files as $file)
// filetype?
$ext = strtolower(substr($file, strrpos($file, '.') + 1));
// let filetypes pass
if(($ext == 'pdf') || ($ext == 'doc') || ($ext == 'docx') || ($ext == 'xls') || ($ext == 'xlsx'))
{  ?>
<td class="file"><a href="/<?= $file ?>" target="_blank"><?= basename($file) ?></a></td>
<td><?= $ext ?></td> 
<?php } } ?>

This is a great tip and addition - thanks for sharing @dirk!

Here you 'll find a demo:


This topic was automatically closed after 11 hours. New replies are no longer allowed.