Skip to main content
Topic: What file did you edit? (Read 15123 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: What file did you edit?

Reply #15
A couple of things I noticed while looking at the package. ;)

Code: [Select]
<file name="THEMEDIR/languages/english/ManageSettings.english.php">
should really be:
Code: [Select]
<file name="LANGUAGEDIR/ManageSettings.english.php">

ManageSettings.english-utf8.php doesn't exists in ElkArte because there is no support for non-UTF8 charsets, so the "-utf8" has been stripped.

This is related to SMF instead: you should **never** mix UTF8 and non-UTF8 charsets modifications in the same file. You should always have one file for each charset (not for language, but some language use different charsets).


And not necessary, but probably "nice" (as in less typing lol):
Code: [Select]
<file name="SOURCEDIR/admin/Admin.controller.php">
could be:
Code: [Select]
<file name="ADMINDIR/Admin.controller.php">
Bugs creator.
Features destroyer.
Template killer.

Re: What file did you edit?

Reply #16
I surely have to learn more on this. Thanks for the guides. I'll have a go again and update it here afterwards.

Re: What file did you edit?

Reply #17
Ok. I got it now. Except for LANGUAGEDIR, I noted that we need to add /english too. Other than that, perfect. I can start doing some test porting.

Re: What file did you edit?

Reply #18
Yes, of course I forgot english... :-[
Bugs creator.
Features destroyer.
Template killer.




Re: What file did you edit?

Reply #22
Ah, okay. Well, then @ahrasis , you should use that hook instead of doing code edits ;)

Re: What file did you edit?

Reply #23
Thanks. I am learning how to create all the "hook" things as we speak. I will try to create that one for fun of learning. But doing that seems quite tedious to me as my need is quite small only. Those with greater needs may attempt this menu creation and rearrangement like a portal mod etc. Let's see how far I can go with this.

By the way there is some bug detected while posting this in my son's ipad mini. In the preview screen, the menu is stucked in the middle of the input box. When the preview is shown just right after the preview button is clicked, try clicking back at the input box as the menu simply sticked on the input box and not on the top.

Re: What file did you edit?

Reply #24
As I mentioned before, loadLanguage() needs a hook. I think the best spot would be https://github.com/elkarte/Elkarte/blob/master/sources/Load.php#L2299

It might need a lot of things passed to it to make it make sense: $template_name, $already_loaded, $attempts, $found, and $fatal.
Just to put ourself on the same line, what would you use the hook for?
In the other topic you talk about logging, but an hook just for logging seems a bit overkill, I would add it to the debug class (that is present starting from 1.1, so it would be a bit limited for now, yeah...). Another thing that comes to my mind, would be load languages from external applications (maybe for integration?), in that case could be better to have something similar to the integrate_verification (I think) hook? So a loop through all the hooks and get as return an array of successful files loaded out outside to be removed from the list? In a similar case, then, the hook would be better before loadLanguage tries to load the file itself? In other words giving priority to the external loading.
Or there are other things?
Bugs creator.
Features destroyer.
Template killer.

Re: What file did you edit?

Reply #25
So you can change a language file with a mod without editing anything else.

Re: What file did you edit?

Reply #26
I have try the hook things (in SMF) and find that it really works in re-organizing my admin menu just fine. However, the menu is now on a separate subs file and mod installation won't affects that file at all. I guess it is still good to edit source file rather than creating a new one. The new file definitely will not be affected when a mod is install while default source will. Unless, a totally new menu need to be inserted, that will be a different thing altogether since it can be inserted at any part of the default menu / sub menu via the hook stuff.

Re: What file did you edit?

Reply #27
Hm... It seems this topic is far to complicated for my simple mind. :-[

I want to write a little addon which changes a link in the menu. I downloaded some addons and had a look into package-info, but there are no strings like "search for this and change it into that" as I know them from SMF modifications.

Will anybody write a small, easy to understand manual how addons must look like with ElkArte?

Re: What file did you edit?

Reply #28
Indeed you will not see many "search for, replace with" addons for ElkArte, we are really really trying to move away from that since it makes upgrades and support and addons more fragile.

Instead of the "search for, replace with"  which are generally referred to as code edits, instead what happens is a named hook is called.  Now there are many 100's of named hooks.  Often these hooks are in the same area's that in the past you would have made the code edit. 

What the hook does is call a function that you "register" with the named hook, that function is passed a set of values from that area of the code.  So for example you use one of the menu hook's, it will be passed the menu array which you manipulate (add, edit, delete keys etc).   Most often the updated array is returned automatically to the calling hook.

This hook then has the same effect of the search and replace but without all of the longterm downside.  Indeed it can look like a lot more work for a simple edit, but trust me, its well worth the up front effort to avoid problems.

If you provide an example of what you want to do, I'm sure a quick real life example could be posted.
Be safe, Be kind, Happy Programing