widgetdotcms

how to add a container/widget/simple widget/vtl file dynamically in dotCMS


Scenario: I have an autocomplete country widget. So when:

  1. I start typing a country name in the textbox, the countries that match that query appears. Lets say I type "Co" and it shows me "Colombia" and "Congo" in a list.
  2. Then I select "Congo".

When I select Congo I want to call a Widget/Container/vtl file/whatever that brings me the information I want formatted the way the widget is formatted. Lest say, all the info of the Congo, Location, Population, a brief description, etc.

I tried with the RestAPI and thought of using dotParse()? But I'm new on this I have no idea if this is even possible. I searched in the docs, but didn't find anything similar.

So how can I do this possible?

I have the Widget created, do I only need to call it via the RestApi?

Do I have to create a Container first?

Thanks in advance, for your help.

Thanks i


Solution

  • It sounds like what you want is the RESTful widget API. This is a remote call that will return your widget rendered. See:

    http://dotcms.com/docs/latest/WidgetAPI

    and

    http://dotcms.com/docs/latest/remote-widgets