This project is read-only.

Show a subset of fields depending on context

Topics: Customizing Orchard
Aug 8, 2013 at 12:01 AM
Hi guys,
I am working with a content type which can be modified by end users (new fields can be added). So I know nothing about those custom fields and can't create a template with explicit field names for that content type. Currently I use Display(Model) to show ALL fields.
But I need to show a subset of fields ONLY depending on the context. Is there any way to achieve it?
Aug 8, 2013 at 2:15 AM
Not enough information. What is supposed to determine what's shown and what's not?
Aug 8, 2013 at 2:09 PM
Hi Bertrand, thanks for your answer.
Well, your question made me to think over it again :)
My content type's fieldset actually can be divided into two parts: "static" (initially defined) fields and "dynamic" fields (added by end users). I could explicitly define different templates for the static fields and choose views in the code depending on the context.
The question is how to add the dynamic part fields to that template if I want it? I mean I need to show ONLY dynamic fields (static ones are already there).

I thought that may be an idea of sectioning fields would be helpful here.
For static fields we can store the information in the DB or in the config file as a list of sections for the content type with some context condition (may be user role,... or rule name?) and a flag (Show, Not Show) and a list of fields with appropriate section number(a field could belong to a few sections).
For dynamic fields it is more complex because I realize that I need to add a UI to determine that sectioning by end users but anyway it is doable as far as I understand.

A bit more simplified variant is if all dynamic fields will be in one predefined section so we don't need additional UI then (although sometimes it is useful for styling to distinguish different fields!).

So all above set against a possibility to show not ALL fields at once but only ONE section. You could combine the view showing section by section though (or combine a static view with showing section by section).

What are my possible approaches then?
I really appreciate your answer.
Aug 8, 2013 at 7:41 PM
Aug 11, 2013 at 12:09 PM
Thanks a lot. I'll have a look if it can give me what I want to achieve.