Hi,
Since rules can't be rearranged, are they query-wise fired from top to bottom?
I'm trying to have 2 separate rules in that order:
- Frontend editable checkbox field gets checked on a post (Pass On Field rule)
- Flag the node if that editable checkbx is checked, then reset a certain editable dropdown field's value and do a page redirect (Pass On rule)
The thing is, if it all gets executed from top to bottom, "Pass On" comes before "Pass On Field", but "Pass On" should be the final reset and redirection. The redirection doesn't happen with the field method, only when clicking the direct flag link.
I decided to use a field checkbox for cosmetic reasons since the flag toggle appears in the node body. I would like to generate a layout block for the flag link. If you got anything please let me know.
Clicking on "Save" if the checkbox is checked should basically constitute a "Content updated" event, but the rule doesn't fire so far. Is saving an editable field a content update?
Comments
Hi flightrs. You have several questions packed into one posting ;-)
To answer your question about rules order:
Rules are triggered by hook invocations. For example, when you save an existing node, that invokes
rules_entity_update()
, which is an implementation ofhook_entity_update()
. So, only rules that respond to the event "After updating existing content" will be invoked. Rules that correspond to other hooks that happen during a node save (e.g.hook_entity_presave()
- which corresponds to the event "Before saving content") will be invoked in the order of the hook invocations. In Backdrop,hook_entity_presave
is always invoked beforehook_entity_update
, and therefore those rules with event "Before saving content" will always be invoked before those with "After updating existing content", regardless of where they appear in the UI.Now, if you have multiple rules that react to the same event, then the order will be the one shown in the UI. The UI order corresponds to the
id
column inrules_config
, from smaller to bigger. So, if you have two rules that react to "Before saving content", and you want rule B to be invoked later that rule A, then you should create rule B after you create rule A. There is no reordering of rules in the UI, as you noticed.I see in your snapshot that you have an event "A node is bing flagged, after Pass it on". Is that a custom event you created? Is it attached to a specific hook in Backdrop?
In the latter part of your message you ask "Is saving an editable field a content update?". Are you referring to the editable fields that the module Editable Views provide? If so, the answer is yes.
hook_entity_update()
and therefore the rules that react to "After updating existing content" are all invoked.Hi, argiepiano,
Thanks a lot for explaining the presave and update part, and the rest. It's much clearer now for further proceedings.
I certainly am using the "Editable Fields" module - which provides the perfect frontend placements for users to edit fields of a post without opening the "Edit" page. As for the flagging custom event; i only installed the Flag module and enabled "Flag actions" - using it straight out of the box.
The events were there like this:
It's a bit of a tricky interplay of things, so i was trying to "sneak in" further explanations of the rest of this system.
I would like to shift my question over to different rendition of the issue.
Basically, there are 2 ways a user can interact with a node, and give it a "Classification":
[faulty*] = The problem is, when the user sets a dropdown field value and saves it, but decides to "Pass it on", then the chosen dropdown field value stays set - and even overwritten with the default value - while it actually should be resetted.
Set data value
" unfortunately overwrites the selected termLet's say the user selects the 4th item, "Top Secret", and saves it - but then decides to pass the node on:
That would result in this:
Dropdown menu
(Highlighted item equals first one):
This 4th element, "Top Secret", gets rewritten with the default term "Unclassified", even in the backend taxonomy:
(Before any questions: it's for a roleplay/game website!! :) )
In summary, that's the current puzzle. I haven't found anything else than "
Set data value
", going forflagged-node:field-classification:name
.I was about to abandon the idea of linking of a boolean field with a flag and rely on using the flag alone instead, but i can't blockify the flag. A solution to that part would be specifically great. (Could it be done in a view block, in context of the current node?)
I figured the boolean field does connect to the flag toggle, but not acting on the true/yes state. Since there's only "Set data value", i've been looking for something that is equal to "choose data value" which does not overwrite the selected term.
Hope it all makes sense, my questions are a bit clustered - and so is my thinking process at this moment! I will continue dabbling around. I'm eager to hear suggestions. Will be definitely busy all day and night with this.