Permalink
Browse files

No commit message

  • Loading branch information...
1 parent 298a153 commit 8e6c8849a45794d53359098dc629920323cea8ba @croaker000 committed Oct 11, 2011
Showing with 11 additions and 4 deletions.
  1. +1 −0 README
  2. +10 −4 function.filelist.php
View
1 README
@@ -18,4 +18,5 @@ Parameters:
"rest" = "true" skips the first item in uploads sub-directory and shows the rest ie. {filelist dir="newsletters" rest="true"}
Change History:
+v1.02: Added "trim" parameter
v1.01: Original code taken from file-list v1 and rehashed to fit correct build syntax
View
@@ -1,7 +1,7 @@
<?php
#CMS - CMS Made Simple
# <filelist> user defined tag
-# v1.10
+# v1.02
# based on FileList-v1 http://dev.cmsmadesimple.org/projects/file-list
function smarty_cms_function_filelist($params, &$smarty) {
@@ -26,21 +26,26 @@ function smarty_cms_function_filelist($params, &$smarty) {
closedir($handle);
if ($params['first'] == 'true') {
$f = $listing[0];
- $html.= "<a href='$dir/$f' target='_blank'>$f</a>";
+ $r = 'uploads/'.$params['dir'].'/'.$f;
+ $html.= "<a href=\"$r\" target=\"_blank\">$f</a>";
} else {
$html.= '<ul class="filelist">';
$count = 0;
foreach ($listing as $f) {
if (($params['rest'] == 'true') && ($count == 0)) {
//skip
} else {
- $html.= "<li><a href='$dir/$f' target='_blank'>$f</a></li>";
+ $r = 'uploads/'.$params['dir'].'/'.$f;
+ $html.= "<li><a href=\"$r\" target=\"_blank\">$f</a></li>";
}
$count++;
}
$html.= '</ul>';
}
}
+ if (isset($params['trim'])) {
+ $html = str_replace('>'.$params['trim'],'>',$html);
+ }
}
} else {
$html.= '<p style="color:red;">Error: Directory ['.$dir.'] not found</p>';
@@ -54,6 +59,7 @@ function smarty_cms_help_function_filelist() {
echo '"dir" = uploads sub-directory to monitor ie. {filelist dir="newsletters"}';
echo '"first" = "true" displays just the first item in uploads sub-directory to monitor ie. {filelist dir="newsletters" first="true"}';
echo '"rest" = "true" skips the first item in uploads sub-directory and shows the rest ie. {filelist dir="newsletters" rest="true"}';
+ echo '"trim" = "value" trims out specified text from returned list ie. {filelist dir="newsletters" trim="newsletter_"} = converts all "newsletter_20110901.pdf" to "20110901.pdf"';
}
function smarty_cms_about_function_filelist() {
@@ -62,7 +68,7 @@ function smarty_cms_about_function_filelist() {
<p>Version: 1.01</p>
<p>
Change History:<br/>
- v1.01: Original code taken from file-list v1 and rehashed to fit correct build syntax
+ v1.02: Original code taken from file-list v1 and rehashed to fit correct build syntax
</p>
<?php
}

0 comments on commit 8e6c884

Please sign in to comment.