Page 1 of 1

Extensions display order - any rules?

Posted: Fri Sep 02, 2016 8:39 am
by Zyleta
I have a question, because I'm wondering, how it is with extensions, when they used same EVENT.

I mean, I have 2 extensions: ext1 and ext2, both use same event: example_event.

Is there any rule, that makes one of this extensions to be displayed first? I mean, e.g. ext1 shows "age", ext2 - "group". Is there anything that can change order of displayed extensions? How it works? The first installed extension is 1st, or last when displayed? Any kind of code makes some extensions "more importand" then the other to makes it 1st? It depends on extension name?

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 8:50 am
by Zyleta
I makes some tests, but I want a confirm - first of it depends on author name (alphabetical order), then extension name (alphabetical order) - is that true?

And it is possible, to change this order to another one, by adding some code into this extensions, or anything else?

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 10:57 am
by david63
Zyleta wrote:first of it depends on author name (alphabetical order), then extension name (alphabetical order) - is that true?
Yes and no. In practise you will probably find that happening but the "official" answer is that events are loaded in a random order.

You can, however, add a parameter to the items in the getSubscribedEvents() function to specift the order in which events run. There is a topic somewhere about this but I cannot find it at the moment but basically you would have 'core.page_header' => 'array(page_header', 5),

From memory the lower the number the higher it will run - omitting that value mean that it will use the default (99?)

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 11:48 am
by Zyleta
Ty for Your reply.
So that means, that extensions which adds/change only style (I mean, doesn't have listener, only style folder inside), will have "random order" or I have to add listener to it, if I want control order of them

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 11:50 am
by david63
Zyleta wrote:Ty for Your reply.
So that means, that extensions which adds/change only style (I mean, doesn't have listener, only style folder inside), will have "random order" or I have to add listener to it, if I want control order of them
You cannot control the order of template events

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 12:16 pm
by Zyleta
I mean, control order of extensions, which uses only template events, which uses only style files.
Uhmm.. I mean, as simple as possible extensions, where I don't use listener, when I use only template events.

On example (as simple as possible, but not useble):
I have two extensions.
1. "username_on_index", which uses EVENT index_body_markforums_before and in file index_body_markforums_before.html have only this:

Code: Select all

{S_USERNAME}
2. "welcome_on_index", which also uses EVENT index_body_markforums_before and in file index_body_markforums_before.html have only this:

Code: Select all

Welcome, 
In those two extension, only what I need to work is composer.json, README.md (not needed?), license.txt (not needed?), and styles/prosilver/template/event/index_body_markforums_before.html

But now, I don't have control at the order, and from my tests, I know that it would by displayed like this:

Code: Select all

ZyletaWelcome, 
because "username_on_index" is before "welcome_on_index" (that "random order"), and if I would have it displayed correctly, I can change the name from "welcome_on_index" on e.g. "index_welcome" - the correct would be

Code: Select all

Welcome, Zyleta
But, like You said before
david63 wrote:You can, however, add a parameter to the items in the getSubscribedEvents() function to specift the order in which events run. There is a topic somewhere about this but I cannot find it at the moment but basically you would have 'core.page_header' => 'array(page_header', 5),
but this can't makes the correct order in this situation?

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 12:22 pm
by david63
Currently there is no way to do it in core phpBB (and I am not aware that there is anything planned to change that in the immediate future)

There is one possible way around this and that is to put an event within the extension's template file that the other extension can utilise, but that requires the co-operation of both extension developers.

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 9:49 pm
by Lumpy Burgertushie
didn't I read somewhere that they would show up in the order they were installed? therefore, you could uninstall them and change the order of installation to get them in the order you wish.


robert

Re: Extensions display order - any rules?

Posted: Fri Sep 02, 2016 10:12 pm
by david63
Lumpy Burgertushie wrote:didn't I read somewhere that they would show up in the order they were installed? therefore, you could uninstall them and change the order of installation to get them in the order you wish.


robert
I think that was a theory in the "early days" of extensions but it most definitely is not the case

Re: Extensions display order - any rules?

Posted: Sat Sep 03, 2016 2:21 am
by 3Di
david63 wrote:
Zyleta wrote:first of it depends on author name (alphabetical order), then extension name (alphabetical order) - is that true?
Yes and no. In practise you will probably find that happening but the "official" answer is that events are loaded in a random order.

You can, however, add a parameter to the items in the getSubscribedEvents() function to specift the order in which events run. There is a topic somewhere about this but I cannot find it at the moment but basically you would have 'core.page_header' => 'array(page_header', 5),

From memory the lower the number the higher it will run - omitting that value mean that it will use the default (99?)
viewtopic.php?p=14468386#p14468386