Populate parts/content-types/mixins etc. based on existing content

Hi!

I would like to be able to populate selection-options/checkboxes/radio-buttons etc. with data depending on existing content.

Example:
Content-type article has a field color. I would like to create a part where it’s possible to select one or many colors depending on which colors have been added to articles.

Hmmm. To me this sounds like the tag input type?

Hi!

No, I think my example was more confusing than helpful…

Basically, I would like to be able to populate a select-option in a part, where the options are a result of a query.

As of now the only way to do this is with the ContentSelector. But that demands that you create a separate contenttype for just this data and store it somewhere, to use as reference in your contenttypes, then fetch that in your part.

We can’t pass logic like you explain into a parts contentselector (“show me only content that has been used in articles”). It will get everything of one type.

Does that clear things up? We’re ofc happy to receive feature requests on improvements.

Ok, thanks. This would’ve been a really nice feature imo.

I’ll figure out a work around.

Just one more comment about ContentSelector, you can filter on a path and type.
So you can for example have a folder with colors, and make the ContentSelector point to them.

<input name="color" type="ContentSelector">
  <label>Select color</label>
  <occurrences minimum="0" maximum="1"/>
  <config>
    <allowType>my.other.app:color</allowType>
    <allowPath>${site}/colors/*</allowPath>
  </config>
</input>

http://xp.readthedocs.org/en/stable/developer/site/input-types/index.html#contentselector

2 Likes

Nice tip, @aro!
I knew you could filter on content type, but the path-filtering was new to me.

FYI! We will be creating a customSelector where you can provide the result programmatically!

3 Likes

@tsi Perfect! Thank you!

The customselector was released in 6.7. Closing this issue.