4

I am publishing everything in the broker database and able to fetch entire component value with the help of ComponentPresentation class and ComponentFactory class. I am using ComponentPresentation.getContent(true) method to fetch the entire content. But my requirement is to retrieve some specific field value from one of the component. but i am unable to do so. Can anybody tell me with an example how I can do that?

3 Answers 3

6

When you publish a ComponentPresentation, Tridion renders the data from the component using the component template. The structure of the component as stored in the content manager is not available to you in the broker, just the rendered output.

The solution depends rather on what you are trying to do. If you just need to have the field available in the same piece of rendered output, then simply amend your component template to make this so.

If you need to get a specific field for some other purpose, you could also consider creating another dynamic component template that renders just the data from that specific field. Then you can query for that component presentation in your web application. (Obviously, you could go too far with this approach - it wouldn't be pretty if you had a component template for every field.)

Some people build their web applications in a way that there's only very simple templating in the content manager, usually the component template renders an XML document which contains everything from the component. Then you can build data structures in your web application that allow you to access each field. If this approach is what you want, then you should look at Dynamic Delivery for Tridion (DD4T) which is a framework which takes care of much of the work of building this kind of application. Also, have a look at the SDL Tridion reference implementation, which builds on DD4T to demonstrate further useful techniques.

5

In broker final content (xml or html as per your architecture) is published. individual field values (as key values) are not published, so You can not directly fetch any component value. you have to parse your Xml/Html to get that field value.

one of the possible way could be to use metadata, to directly fetch the value from broker.

1

Somewhere in your solution you need to transform your "naked" content into it's presentation form (usually HTML for web purposes; either directly or via ASP.Net/JSP). With Tridion this is traditionally the responsibility of your page and component templates.

Recently another approach has gained momentum which is DD4T (Dynamic Delivery For Tridion). With DD4T you publish the content "as is" to the broker and consume the content on the content delivery side in an MVC application; it appears that this is what you are doing (consuming content from the broker in your web application) so you might want to take a look at DD4T.

Alternatively you could write your own solution to push data into the broker and consume it on the other side but that seems like reinventing the wheel...

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.