News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

loadTemplate, loadLanguage & CSS from a custom folder?

Started by e_xrt123, September 05, 2017, 05:42:40 PM

Previous topic - Next topic

e_xrt123

Hi,
I'm writing an extension to my SMF forum (basically a custom action with few sub-actions), and as far as it was a small project just for testing it was OK. But it's getting bigger and bigger and I'm kinda tired of scattering all my files across different folders like Themes/default, Sources, Themes/default/languages etc etc.
Is there a way I could store EVERYTHING in a single folder? Like a folder located in SMF's root called "MyAction" and it would contain the source file, template file, CSS and language files?
I know I could probably modify SMF's functions to do this but I don't want to interfere with SMF internals.

Suki

Not without some changes to the core. Some functions allows loading from a different path but not all of them.

What are you trying to do?  if you're worried about having to open files fomr mulriple places, try using an editor with tree view.

In theory, an action only needs a single controller, model and view, if you have more than one of those for a single action thats an indicator theres something wrong in your architecture.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

e_xrt123

It's not really that big but I'd prefer to have it all in one place so it's easier for me to maintain, edit and it also looks better as it's not an internal part of SMF but my "mod", I'd prefer to have it outside of SMF but still integrated with it.

What if I'd make it as an external page? Could I get user's language and language strings from $txt through SSI? So the user would just click a button and it would redirect it outside of SMF (to a sub folder) but it would still keep him logged in etc and I could use SMF's variables like $txt, $context, $smcFunc etc?

Arantor

It requires some quite serious changes to do it because loadTemplate and loadLanguage are designed to support multiple specific folders for themes.

Though honestly, if managing 3 folders is too much like effort, good luck doing anything else.

Suki

Besides, if you are truly making a modification then you can have your files arranged the way you want and use package-info to properly put them on their respective folders on install.

If you don't want to use the packager manager, a simple batch/bash script with some xcopy/mv, cp, rm instructions will do the job just fine.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: