Hi all,
I'm writing a snippet, now I want to write some cache-files on the server, specifically some generated images. Where should the snippet write those files?
I mean: I know I can write whatever I want, but is there a standard about where a snippet should write his own files?
Daniele "MadMage" Calisi
-
☆ A M B ☆
- 3,141 Posts
When talking about caching I would opt for core/cache (using the cachemanager:
http://modxcms.com/forums/index.php/topic,67496.new.html).
When you are storing static generated images I would probably go for assets/components/mycomponent/files/name.jpg.
-
☆ A M B ☆
- 3,112 Posts
I have a different habit.
I tend to save images (or files) that are generated by snippet to be out of the component's folders (/core/components/ or /assets/components/).
Why?
Because uninstalling the package would also remove those component's folders, including all the contents.
Why should you uninstall your package, you may ask.
Let's say, at some point, you just want to create another version of your snippet, but collecting the same files (data) with the previous one.
Wanna test? Install Gallery, upload some images, then uninstall it back. (This would also remind you to change the gallery's image path on the system settings once you install Gallery package).
It's not a bug. Just a default action.
My suggestion, just save your files under the /assets/[images|files|...]/
Rico
Genius is one percent inspiration and ninety-nine percent perspiration.
Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
www.virtudraft.com
Security, security, security! |
Indonesian MODx Forum |
MODx Revo's cheatsheets |
MODx Evo's cheatsheets
Author of
Easy 2 Gallery 1.4.x,
PHPTidy,
spieFeed,
FileDownload R,
Upload To Users CMP,
Inherit Template TV,
LexRating,
ExerPlan,
Lingua,
virtuNewsletter,
Grid Class Key,
SmartTag,
prevNext
Maintainter/contributor of
Babel
Because it's hard to follow all topics on the forum, PING ME ON TWITTER
@_goldsky if you need my help.
-
☆ A M B ☆
- 3,141 Posts
That's true, it can remove it from the components folder.
I would not want any random component messing with my own assets/images directory though.
Assuming we're talking extras that are meant for distribution, I'd say either offer the option (during install + edit later through settings) to choose where it's saved, or put it in the components dir.
In the end the beauty is that you can do it exactly how you want to
Ok thanks,
I was wondering how this should be done "officially", if I would like to write an extension. I think that it should be better to have a standard, at least as a "default" behavior, so that the extension have a similar behavior.
However, since there is no standard (so far), I will follow one of your advices ;-)
Daniele "MadMage" Calisi
-
☆ A M B ☆
- 3,112 Posts
It began from MODX Evolution, that by convention all user files were placed inside the assets/ folder, while the other elements were inside assets/snippets, or assets/plugins, or assets/modules.
Images were usually stored in assets/images/ , docs were in assets/docs or assets/files , templates were in assets/templates .
MODX Revo adopts the behavior to put all add-ons under assets/components/ .
Well, you know the rest.
Rico
Genius is one percent inspiration and ninety-nine percent perspiration.
Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
www.virtudraft.com
Security, security, security! |
Indonesian MODx Forum |
MODx Revo's cheatsheets |
MODx Evo's cheatsheets
Author of
Easy 2 Gallery 1.4.x,
PHPTidy,
spieFeed,
FileDownload R,
Upload To Users CMP,
Inherit Template TV,
LexRating,
ExerPlan,
Lingua,
virtuNewsletter,
Grid Class Key,
SmartTag,
prevNext
Maintainter/contributor of
Babel
Because it's hard to follow all topics on the forum, PING ME ON TWITTER
@_goldsky if you need my help.