The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Custom classes/pages placement without disturbing core - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Custom classes/pages placement without disturbing core (/showthread.php?tid=574) |
Custom classes/pages placement without disturbing core - gaiusjaugustus - 05-24-2017 I'd like to be able to update UserSpice whenever updates are available. But I'm adding functionality. So this is mostly a question of the best practices for placement of files and such. 1) Adding functions My understanding is that all custom functions should go in usersc/includes/custom_functions.php And if I want to add additional files with custom functions, I can require them within custom_functions.php. Is this the best practice? I know I could add an additional require_once to us_helpers.php, but that would alter the core files, which I don't want to do. 2) Adding pages My understanding is that custom pages can be added to the users/ folder. Should I be adding them to usersc directory instead, or is the users folder a more appropriate place for them? I haven't tried usersc yet to see if they even show up in the Admin Dashboard as pages. 3) Adding custom Validation (and maybe other classes in the future) I've found that I need to validate dates as well as the currently available validations. I don't necessarily want to add to the current Validate class since that will alter core functionality. Where should I put a file with new classes? My first thought is to add a folder to usersc and then require from the custom_function.php, but that may be naive? Thanks in advance for your suggestions. Gaius Custom classes/pages placement without disturbing core - mudmin - 05-25-2017 Yes. Sticking that sort of thing in usersc is absolutely the way to go. You can feel free to add additional files to the users folder, but changing existing ones is where you get into troubles with updating. You can add pages wherever you want. I tend to do mine in the root below the users folder. The idea behind the users folder is it keeps all the user "junk" out of the way of your design so you have a clean space to do your own project in the root and any other subfolders you want to use (just add additional subfolders in the us_url_root or whatever it's called in the root folder). Userspice doesn't really care where you put your own folders. You can put new classes in the classes folder and just add the include in your users/init.php file. You won't have any issues with that because we can't patch your init file without breaking the whole project, so if anything needs the be patched there, that's something you have to do. I hope that helps. |