3

Is it possible with broker query to match the component field value? I have to match the component field value also other than different criteria. Field is of string type and multi valued. Please suggest if it is possible to do?

1 Answer 1

7

Regular component fields cannot be queried in the content delivery system, as only system metadata, component metadata fields and taxonomy fields are stored there with the templates output.

If you're only dealing with a few components you could load them all and check the Component Presentation content, but this is inefficient. You could move your content field over to a metadata field and use Core Service to update and re-publish all of your components, thereby making the field query-able.

Other solutions I've seen are Event Systems to copy values over from regular fields to metadata fields on save and (if I recall correctly) Storage extensions which create additional metadata when the Component Presentations / Pages are stored.

4
  • 2
    I'd avoid checking the CP content - irrespective of client/technical team promises that the strcuture (etc.) won't change - it will - and your code will be "wrong" ;) /// Though perfectly feasible (and on the face of it quite simple) - moving to the metadata due to the technical restrictions of the broker querying should be challenged by your architect / content modeller. /// +1 for the Event System - be careful to ensure that these fields are clearly labelled / sectioned (and perhaps protected) so that editors are not confused and edit them directly. Commented Oct 13, 2016 at 9:52
  • Agreed. Checking the Component Presentation content is a poor solution. Just offering it as a way out of a hole. Commented Oct 13, 2016 at 9:55
  • 1
    Of course David, I knew that you had offered just as it is an option - I just wanted to be explicit - many many years ago (in the early days) I did something similar having been fooled into trusting the tech lead in terms of "just a temporary solution" and "it'll never change anyway" ;) Commented Oct 13, 2016 at 10:01
  • Ah, yes, the fabled "temporary solution" ;) Commented Oct 13, 2016 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.