Search

I think Brendo means adding a priority function like so:

public function priority(){
    return Event::kHIGH;
}

That seems to work.

But: I can not replicate that events with the same priority are executed in alphabetical order. In my test it is the other way round.

Brendo?

public function priority() {
    return Event::kNormal;
}

One form can have as many actions as you need, it’s actually done with straight HTML, there’s nothing fancy about it all.

Say you have a standard form that just has two fields, Name and Email. For some reason, the Name is stored in the Names section and the Email is stored in a separate Email section.

You can save both these fields to two sections using the same form with default Symphony events.

Create two events, one for the Name section (save-name), one for the email section (save-email). Attach both to your page. See the example HTML and bingo :)

<form>
<label for='name'>Name</label>
<input name='fields[name]' id='name' />
<label for='email'>Email</label>
<input name='fields[email]' id='email' />

<input type='hidden' name='action[save-email]' />   
<button type='submit' name='action[save-name]'>Save</button>
</form>

@michael-e I don’t think it was ever meant to be alphabetical order, rather numerical. I know in an old 2.0.6 build we used 1_save_order, 2_process_order naming convention. I’ll have a look though.

edit I can reproduce the reverse alphabetical event processing on a 2.1.2 build.

edit 2 This is has been fixed in this commit ;)

@michael-e I don’t think it was ever meant to be alphabetical order, rather numerical.

A long time ago I learned that it’s alphabetical. And this is why alpacaaa uses events named “aaa Save articles”. Is this common misbeleif?

edit: Once again I was typing too slow, so Brendo outperformed me… Thank you, Brendo!

Not so much misbelief, it was correct until Alistair’s commit. The reason being is that events were just executed in the order returned by the EventManger->listAll function, which is alphabetically from the filesystem.

Thanks for all the info, my first set of events should go without a hitch now…

On of my actions relies on another being done… is there any way of returning info from one event to the next?

No, you can’t chain events like datasources unfortunately. In the past we’ve customised the events so they modify the $_POST variables to add new actions and data to do this sort of chaining

Right then, time for some Event customisation! lol

Is it also possible to manipulate the execution order of datasources?

I believe they are executed first in order of dependency (chaining) and then alphabetically.

Is there any way how I can change this? I need the param-output of one datasource do handle some logic in another, custom datasource. Is the only way changing the name of the datasource?

Are there plans for adding a priority()-function to datasources in the future (S2.2.1 for example)?

As Nick said, you can use datasource chaining to define the order. Use something like

public function __construct(&$parent, $env=NULL, $process_params=true){
    parent::__construct($parent, $env, $process_params);
    $this->_dependencies = array('$ds-titles-single', '$ds-issues-single', '$ds-pages-single');
}

as the constructor to run the datasource after the DSs titles-single, issues-single and pages-single, all with some output parameter. (I don't know if they actually need an output parameter set.)

As long as you chain datasources there's no need to change their name.

If I remember correctly, in your custom ds you just need to populate the $this->_dependencies array with the param-output of the ds that should be executed first.

EDIT: too late :)

Thanx! I'll look into $this->_dependencies, it looks like that is what I need. So I just fill that array with the parameters I need?

Allright, now my custom datasource outputs some ID's as parameters, only the next datasource that needs those ID's gets executed before my custom DS outputs the parameters.

Also when I add the name of my custom parameter output to $this->_dependencies. Any thoughts on this?

Hmmm... is there some specific pattern for outputting filter-parameters for custom datasources? I noticed that when I change the name of my custom parameter to ds-(handle of my custom datasource) the execution order works as expected. When I outputted a parameter-name that was totally different, the execution order was ignored, even if I putted the parameter manually in $this->_dependencies.

Yes, it needs to be the name of your data source, e.g. ds-articles.

Perhaps an idea for an article? A little how-to with the ins & outs and tips & tricks for custom datasource / events development?

What's currently the recommended way of ordering/prioritizing event execution?

I remember reading something about it a while ago, but can't find a Guide, Tutorial, Article or Concept at the moment...

Checkout this gist from Brendan.

Thanks. And nevermind, just found it in the API docs. ;)

I know there a lot of very useful gists from Brendan and other people out there, but it's really hard to find them when you're looking for a specific topic.

Symphony's documentation is too fragmented at the moment. As already mentioned above, we currently have Guides, Tutorials, Articles and a lot of gists floating around somewhere.

While Concepts, API docs and the GitHub-Wiki (for work-in-progress-kinda things) serve different purposes and should remain, I think it would be a good idea to consolidate Guides, Tutorials and Articles into a single section and also put all these useful gists inside.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details