The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom classes/pages placement without disturbing core
#1
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
  Reply
#2
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.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)