kavin
I'm new here

How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Dear All.

We want to populate the  <CMS_INPUT_COMBOBOX> from the Script template, because we are doing some operations inside the script template based on these results we have to populate the contents inside  <CMS_INPUT_COMBOBOX>,

is these possible in FS?

Thanks you!

Labels (1)
Tags (3)
1 Solution

Accepted Solutions
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi Kavin,

I quickly added the solution to a github project:

GitHub - freinhold/firstspirit: FirstSpirit Extensions

See com.reinhold.fs.hotspot.ProjectGroupsHotspot.

Just add it to one of your modules (or create a new one) and define it as public-component in module.xml:

<public>

     <name>ProjectGroupsHotspot</name>

     <class>com.reinhold.fs.hotspot.ProjectGroupsHotspot</class>

</public>

Then you can use it in comboboxes:

  <CMS_INPUT_COMBOBOX name="st_group" useLanguages="no">

    <CMS_INCLUDE_OPTIONS type="public">

      <LABELS>

        <LABEL lang="*">#item.name</LABEL>

      </LABELS>

      <NAME>ProjectGroupsHotspot</NAME>

    </CMS_INCLUDE_OPTIONS>

    <LANGINFOS>

      <LANGINFO lang="*" label="Groups"/>

    </LANGINFOS>

  </CMS_INPUT_COMBOBOX>

HTML-Output:

$CMS_VALUE(st_group.getValue())$              // Get the Java Group-Instance

$CMS_VALUE(st_group.getValue().getName())$    // Get name of group

best regards

Felix

View solution in original post

13 Replies
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

HI Kavin,

I think you have to provide some more details:

When do you want the script to be executed and what exactly does the script? Do you want to change the selected entry in the combobox or do you want to create options for the combobox dynamically? Is it a combobox which shows datasets or manually created options?

Maybe you can provide the definition of the combobox and the scripts (or relevant parts of it)

Best regards

Felix

0 Kudos
kavin
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi Felix,

Thanks for your reply.

We want to create the options in the combo box dynamically which needs to load all the Groups which is associated with that project.

It would be fine, if it can be achieved without script templates.

Best regards,

Kavin

0 Kudos
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

HI Kavin,

for this you have to create a HotSpot (public component) in a module, that provides the groups of the project. (FirstSpirit Online Documentation - CMS_INCLUDE_OPTIONS: Type PUBLIC ).

If you need help with this let me know.

Best regards

Felix

0 Kudos
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi Kavin,

I quickly added the solution to a github project:

GitHub - freinhold/firstspirit: FirstSpirit Extensions

See com.reinhold.fs.hotspot.ProjectGroupsHotspot.

Just add it to one of your modules (or create a new one) and define it as public-component in module.xml:

<public>

     <name>ProjectGroupsHotspot</name>

     <class>com.reinhold.fs.hotspot.ProjectGroupsHotspot</class>

</public>

Then you can use it in comboboxes:

  <CMS_INPUT_COMBOBOX name="st_group" useLanguages="no">

    <CMS_INCLUDE_OPTIONS type="public">

      <LABELS>

        <LABEL lang="*">#item.name</LABEL>

      </LABELS>

      <NAME>ProjectGroupsHotspot</NAME>

    </CMS_INCLUDE_OPTIONS>

    <LANGINFOS>

      <LANGINFO lang="*" label="Groups"/>

    </LANGINFOS>

  </CMS_INPUT_COMBOBOX>

HTML-Output:

$CMS_VALUE(st_group.getValue())$              // Get the Java Group-Instance

$CMS_VALUE(st_group.getValue().getName())$    // Get name of group

best regards

Felix

mbergmann
Crownpeak employee
Crownpeak employee

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi Felix,

great that you share your examples!

One thought (without having tested it): I‘m not that sure if the group‘s numeric id is an ideal candidate for the key when you think of stuff like project export/import or content transport - the name might be a better choice.

Best regards

Michael

0 Kudos
kavin
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi Felix,

Thank you so much for sharing the code.

Best regards,

Kavin

0 Kudos
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

HI Michael,

thanks, that's a good point - I adjusted it in the repo.

kavin​ you should use the adjusted version of the code then.

Best regards

Felix

0 Kudos
kavin
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hi felix.reinhold​,

Is it possible to load the groups in  CMS_INPUT_PERMISSION component?

Thank you!

0 Kudos
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

HI kavin,

you want to...

(1)...load the groups that are available in CMS_INPUT_PERMISSION into the CMS_INPUT_COMBOBOX

          or

(2)...use the project editor-groups in CMS_INPUT_PERMISSION?

For (1) you would have to adjust the hotspot and get the groups from the PermissionService (or parse the config manually).

For (2) you would have to sync the groups into a xml-file that is provided to the PermissionService

Best regards

Felix

0 Kudos