How can I display a shape on demand using a predefined driver? #6870
-
I am trying to display a shape only if the model is allowing to show it. For example I have I am puzzled on how can I display a shape on demand like that? My view would look something like this
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
A basic idea in Orchard is that content types are a composition of independent parts. It seems to me that you're attempting to make one part depend on another one. Since you can't really rely on parts being evaluated (like displayed) in a particular order, I encourage you to change how you approach this task. Can you tell what exactly are you trying to achieve? That being said, here are a few ideas:
Also, you don't have to (or rather, shouldn't try to) explicitly build the display of |
Beta Was this translation helpful? Give feedback.
-
I have a content type called This form will be handled using a single page approach. So when the user submit the form, we'll submit the form using AJAX request and populate the page accordingly. There will be many content-items of the fancypage. The main difference will be what inputs to show on that form. Since I am unable to render one part from another. I should be able to do the same thing from the content-type, right? Then am I able to compose a shape on the fly from my |
Beta Was this translation helpful? Give feedback.
-
As @Piedone said there are many way to do it, e.g. in an overridden template of your parent content type, you can render what you want, we have helpers to retrieve a given part and then check its properties e.g. to not render another part. Hmm, but as @Piedone said maybe better to do it through display drivers, e.g. part1 driver would provide on display its related shape and based on a condition also combine the shape of part2, part2 driver would provide nothing on display. But better to let part2 driver decide itself to provide or not its related shape on display
|
Beta Was this translation helpful? Give feedback.
-
@CrestApps design your Parts as reusable piece of block. If your one part is depends on another part - then you can’t use one part without another - not a good design. Keep |
Beta Was this translation helpful? Give feedback.
-
or you can do something like this:
this could work too |
Beta Was this translation helpful? Give feedback.
A basic idea in Orchard is that content types are a composition of independent parts. It seems to me that you're attempting to make one part depend on another one. Since you can't really rely on parts being evaluated (like displayed) in a particular order, I encourage you to change how you approach this task. Can you tell what exactly are you trying to achieve?
That being said, here are a few ideas:
Display()
in the driver can returnnull
based on the part's content or anything else.PropertyTypePart
's shape inFancyFormPart
you can render an ad-hoc shape there directly (if you want to factor that piece of markup out).Content
s…