Hello,
Is there a module for CMSMS 2.X that works like the old File Listing module? I want to upload files to a directory and view those files on the front end as file name text links.
For example:
file_name_one.html
file_name_two.html
file_name_three.html
Thank you,
Monte
Link all files in a given folder? CMSMS 2.X
-
- Forum Members
- Posts: 64
- Joined: Wed Jul 03, 2013 7:44 pm
Re: Link all files in a given folder? CMSMS 2.X
Think it would be a few lines of php code to write a plugin to output an array with file names.
Below some altered code I'm using somewhere to get a list of image files from a specific folder
In this case the code is used in a UDT which is called with the 'dir' parameter, but if your folder is constant you can hardcode it in the UDT.
The code above doesn't make much sense on its own but may be a starting point for your own UDT/plugin.
Below some altered code I'm using somewhere to get a list of image files from a specific folder
Code: Select all
$dir = $params['dir'];
$config = cmsms()->GetConfig();
$image_uploads_path = $config['image_uploads_path'];
//look for jpg and png files
$pattern = $image_uploads_path . DIRECTORY_SEPARATOR . trim($dir,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*.{jpg,png}';
$images = glob($pattern,GLOB_BRACE);
foreach ($images as $image) {
$basename = basename($image);
echo $basename;
}
$image_folder_url = $config['uploads_url'] . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . trim($dir,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
The code above doesn't make much sense on its own but may be a starting point for your own UDT/plugin.
Re: Link all files in a given folder? CMSMS 2.X
CGExtensions and CGSimpleSmarty both have tags that will build a file list from a directory. You can then use that array to do what you need to do in Smarty.
For example, here's how I've used it in LISE to build a lightbox gallery from all of the images in a folder:
For example, here's how I've used it in LISE to build a lightbox gallery from all of the images in a folder:
Code: Select all
{if $item->fielddefs.image->value}
{$path="images/artists/{$item->fielddefs.image->value|dirname}"}
{$files=cgsimple::get_file_listing($path,'thumb_')}
{foreach $files as $file}
<a class="featured-image" href="{uploads_url}/{$path}/{$file}" data-lightbox="featured">
{CGSmartImage src1="{uploads_url}" src2=$path src3=$file noembed=1 filter_croptofit='75,75,c,1'}
<div class="overlay text-right"><i class="fas fa-search-plus"></i></div>
</a>
{/foreach}
{/if}
Not getting the answer you need? CMSMS support options
Re: Link all files in a given folder? CMSMS 2.X
maybe this will work too:
{assign var='files' value='uploads/album/*.html'|glob}
{foreach from=$files item='file'}
.....
{/foreach]
{assign var='files' value='uploads/album/*.html'|glob}
{foreach from=$files item='file'}
.....
{/foreach]
-
- Forum Members
- Posts: 64
- Joined: Wed Jul 03, 2013 7:44 pm
Re: Link all files in a given folder? CMSMS 2.X
Thank you all for your help. I will give these suggestions a try!