10390 Posts in 2202 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 556 Views |
-
Gallery module with subdirectories

6 May 2010 at 2:59am Last edited: 6 May 2010 3:01am
Hello everybody, here is an idea to display all files (for example images) existing in the selected directory and also in subdirectories for the gallery module (v0.2.2).
I've found a topic about that problem in the archive (http://silverstripe.org/archive/show/225684#post225684) and an enhancement ticket (http://open.silverstripe.org/ticket/3170).
Perhaps someone can add a comment there...OK, here it is:
There is a // TODO comment in the Items() function on line 207 in code/GalleryPage.php
You need to replace it with this lines of code, where it searchs for subdirectories and builds a new extended where query with all FolderIDs/** Searching through sub-directories if required to find appropriate files **/
$subdirs = DataObject::get("File", "`ClassName` = 'Folder' AND `ParentID` = '{$this->FolderID}'", "`File`.`Sort` ASC");
$subdirQuery = '';
if ($subdirs) {
$subdirIDStr = '';
foreach($subdirs as $subdir) {
$subdirIDStr .= " OR `ParentID` = '{$subdir->ID}'";
}
$subdirQuery = "(`ParentID` = '{$this->FolderID}'".$subdirIDStr.")";
} else {
$subdirQuery = "`ParentID` = '{$this->FolderID}'";
}Now we need to add the query to the file select statement...
Replace Line 223return DataObject::get("File", "`Filename` REGEXP '[.]({$extensions})\$' AND `ParentID` = '{$this->FolderID}'", $sort, "", $limit);
With this
return DataObject::get("File", "`Filename` REGEXP '[.]({$extensions})\$' AND ".$subdirQuery, $sort, "", $limit);
@all admins: It would be nice to have a message service in this forum to get in contact with other members
| 556 Views | ||
|
Page:
1
|
Go to Top |

