I would like to ask you to lead me to the right direction. I'm not deep technically in the system right now, but looking for the solution which is not an evil hack in the system, but rather fits to the design of Orchard. The requirement is to calculate the
value of one content field based on the value of other fields of the same item. I do not know what would be the best way to do this.
What I know,that the calculated field has to be updated at every change of the fields from it is derived.
Workflows provide Update and Create actions. I was thinking whether a custom workflow step or a workflow step delivered by orchard where scripts can be used, would be applicable to this. I could make difference using workflows, whether the change is done through
Custom Forms for example or through a dedicated custom action etc. It might a future requirement, to differentiate based on the actions.
Another option in my mind, is to create my own content fields and parts, which is basically UI independent and their methods are executed at every access to the content item. But in the model layer, the information is lost - as I would assume - which action
triggered the change on the content item. Beside this, the content definition feature of Orchard is enough for me rather to create own content fields and parts.
So I would rather do it using workflows. What is your opinion ? Is it possible to define my own workflow task which is displayed in the workflow designer and during execution has access to the content item, and is allowed to change it? For example, after the
content item has been changed but before it is saved.
Here I would like to get the information, whether the events Content Updated, Created are raised before the Save is done, or after. As I experienced in other workflow systems, it is raised before, and I'm able to change the data in the memory before it is saved.
If not, I probably would need to define the Before Save Event, but this would go down deep in the workflow system, because I want to decide, what kind of action started the my workflow.
Please say your comments.
Nov 25, 2013 at 7:52 AM
Edited Nov 25, 2013 at 7:52 AM
Fields (as parts) should be independent of one another in principle. If you have two members that are supposed to be linked like you describe, they should be properties on the same field or part. Using workflows is definitely a bad idea unless I'm missing
something about your scenario.
My requirement should cover the following below.
As It is not possible to use tokens in body part(it is not a templating framework), I would like to change the body content and insert the value of some content fields into the body, extending with some markup. I would like to insert other scripts and iframes
also, to generate a graph based on content field values(or values derived), but aligned inside the body content somewhere, and not sequential after each other.
So summarized I want to fill the body content myself.
I do not want to introduce new content parts and fields for that purpose, but rather create a content type from the standard fields of Orchard and form the body part, and fill the body part at the end.
I was thinking using the cshtml templates/views, and extract the content from the model, and display it with the desired alignment. But this is not enough, I need more than a view, and It would be not nice to place the functions of the model into the view.
I could have more freedom in c# to do everything I need to fill the body content part with a specific generated content.
Would it possible using a module, to evaluate the content item fields and fill the body with my own data ?
Or should I create my own content part which groups my content fields, and also includes a html area ?
Or how would you start with this ? :) Please forgive me, if I have wrong assumptions. I'am not deep in orchard, but studying it, and want to understand and learn. I read and understood a lot till today, but far away knowing everything. If I could get some hints,
which part of Orchard to study to resolve this, It would be a great help for me to focus on the right area.
Thanks and kind regards