Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
File-name based arrays...
zodiacdm
✭
OK, so I am back on the Vanilla project, only this time on a professional level.
I am using Vanilla as a base for my employer's website. I am creating a photo gallery application based on the Addon application used here on the VF.org site. So far so good, though I have run into a snag on something that I have not seen done in vanilla as of yet.
I want to build a model that will allow for indexing of photos already in a certain directory, based on the contents of the file name.
I am using the pages plugin for direct results of my experiments. I have figured out how to display the photos in a certain directory, though I am having trouble breaking down the array of file names into a sub array for each file.
Here is what I have so far...
I'm probably making a newbie mistake, though I can't seem to figure it out.
Any suggestions would be much appreciated. Thanks.
I am using Vanilla as a base for my employer's website. I am creating a photo gallery application based on the Addon application used here on the VF.org site. So far so good, though I have run into a snag on something that I have not seen done in vanilla as of yet.
I want to build a model that will allow for indexing of photos already in a certain directory, based on the contents of the file name.
I am using the pages plugin for direct results of my experiments. I have figured out how to display the photos in a certain directory, though I am having trouble breaking down the array of file names into a sub array for each file.
Here is what I have so far...
I'm probably making a newbie mistake, though I can't seem to figure it out.
Any suggestions would be much appreciated. Thanks.
$ClassDir = PATH_ROOT.'/themes/MyTheme/design/images/namedfiles2009';
$PublicDir = '/website/themes/MyTheme/design/images/namedfiles2009';
///////////////////
function GetFilesInfo($Directory) {
$Files = scandir($Directory);
foreach ($Files as $FileName) {
$Item['FileName'] = $FileName;
$Item['Class'] = (substr($FileName, 0, 3));
$Item['ID'] = (substr($FileName, 3, 3));
$Item['Size'] = (substr($FileName, 6, 1));
if (strlen($FileName) > 11) {
if (substr($FileName, 7, 1) != 'F') {
$Item['Name'] = (substr($FileName, 9));
$Item['Frame'] = 0;
} else {
$Item['Name'] = (substr($FileName, 10));
$Item['Frame'] = 1;
}
} else {
$Item['Name'] = NULL;
$Item['Frame'] = 0;
}
$AllFiles[] = $Item;
}
return $AllFiles;
}
///////////////////
<div id="Custom">
<ul class="Gallery">
<?php
GetFilesInfo($ClassDir);
foreach($AllFiles as $Item){
if (substr($Item['FileName'], 0, 1) != '.') {
if (substr($Item['FileName'], 6, 1) != 'L') {
?><li class ="Item Gallery Image">
<a href="<?php
if ($Item['Name'] != NULL) {
echo '/website/gallery/item' . DS . $Item['Name'];
} else {
echo '/website/gallery/item' . DS . $Item['FileName'];
}
?>">
<img src="<?php
echo $PublicDir . DS . $Item['FileName'];
?>" Class="Gallery Image"></img></a></li>
</ul>
<?php }}}?>
</div>
Tagged:
0
Answers
I had
GetFilesInfo($ClassDir);
I needed
$AllFiles = GetFilesInfo($ClassDir)
That only took me a few hours to figure out :P