Feature Request: Include subdirectories #84
Replies: 4 comments 1 reply
-
@alexanderhorner This has been request before and I know people who have achieved it with custom drivers. Would like to have this as a feature in v1.x but I'll need to try and get the conventions right. Making it configurable AND reliable is important but also a challenge. Here's the first problem I can think of: Say you have the following file The full path could be stored inside of the primary key of the model (perhaps The next option would be making the path configurable and buildable. The new version of Orbit will have a config builder (instead of the separate dedicated methods), so it could look something like: OrbitOptions::make()
->buildPathUsing(function (Post $post) {
return $post->created_at->format('Y/m/d') . '/' . $post->slug;
}); This API feels a little bit nicer imo since it's fully configurable but it is an extra step when working with Orbit. Sub-directories are probably rare at the moment because it's just not possible without a custom driver. The amount of extra code is minimal though. Using this callback approach would work in most scenarios (I think). When creating a new The tricky part with the approach is when we refresh the SQLite cache. At the moment, the cache is re-instated by looping through all of the files and assuming the filename is the primary key (relates to the point earlier). Chances are I'll look further into the 2nd approach since it feels nicer and a little more powerful (user-configurable). Sorry for the essay too, just some of my thoughts on the subject! |
Beta Was this translation helpful? Give feedback.
-
You could start simpler. Use base content directory for creating new files, but also search subdirectories when retrieving. Subdirectories would be completely manual that way and just for the user to order it a bit. |
Beta Was this translation helpful? Give feedback.
-
Just had time to read everything more thoroughly. Thanks for the answer, excited for the future of this project. |
Beta Was this translation helpful? Give feedback.
-
Why not a method on the model like Edit: trait Orbital {
public string $path = '';
public function getOrbitPath(): string {
if $this->path != "" {
// or a more complex solution that allow for things like :id-:slug
return $this->getAttribute($this->path);
}
// current logic
}
} So now if someone needs to customize things a little they can override the getOrbitPath method or just use the property. (note: I never used orbit) |
Beta Was this translation helpful? Give feedback.
-
Currently only files with the right suffix and inside the
content/
directory (or whatever set in the config) are accessible. For large projects it would be great if you could sort your database files into subdirectories.Beta Was this translation helpful? Give feedback.
All reactions